[R] sin(pi)?

2007-09-03 Thread Nguyen Dinh Nguyen
Dear all, I found something strange when calculating sin of pi value sin(pi) [1] 1.224606e-16 pi [1] 3.141593 sin(3.141593) [1] -3.464102e-07 Any help and comment should be appreciated. Regards Nguyen Nguyen Dinh Nguyen Garvan Institute of Medical Research

[R] element wise opertation between a vector and a list

2007-09-03 Thread Yongwan Chun
I want to try to get a result of element wise addition between a vector and a list. It can be done with for statement. In order to reducing computing time, I have tried to avoid for state. If anybody give me an idea, I would apprecite it much. for example, with a b as below lines, a-

[R] how to sub-sample a variable on another file coordinates

2007-09-03 Thread Yogesh Tiwari
Hello 'R' Users, I have a monthly mean CO2 necdf data file defined on 1x1 lat by lon coordinate. I want to sub-sample this variable CO2 on the coordinates of another ASCII data file. The coordinates of another ASCII data file are as: -24.01 152.06 -18.58 150.19 -13.46 148.35 -8.29 147.03

Re: [R] Problem in downloading Yahoo Finance data from R

2007-09-03 Thread Theta
Hello Shubha, alternative method that gets closing prices of the SP500 Index, last line calculates the logreturns, easy to use data. sp500 - get.hist.quote(^GSPC,start=(today - Sys.Date())-735,quote=Cl) rsp500 - diff(log(sp500)) Shubha Vishwanath Karanth wrote: Hi R users, I have a

Re: [R] sin(pi)?

2007-09-03 Thread Olivier Delaigue *
sin(3.141592653589793) [1] 1.224606e-16 Regards, Olivier Delaigue Nguyen Dinh Nguyen wrote: Dear all, I found something strange when calculating sin of pi value sin(pi) [1] 1.224606e-16 pi [1] 3.141593 sin(3.141593) [1] -3.464102e-07 Any help and comment should be

Re: [R] sin(pi)?

2007-09-03 Thread Peter Dalgaard
Nguyen Dinh Nguyen wrote: Dear all, I found something strange when calculating sin of pi value sin(pi) [1] 1.224606e-16 pi [1] 3.141593 sin(3.141593) [1] -3.464102e-07 Any help and comment should be appreciated. Regards Nguyen Well, sin(pi) is theoretically zero, so you are

Re: [R] sin(pi)?

2007-09-03 Thread Simon Blomberg
Umm. pi has been rounded to 6 decimal places in the second example. So it isn't surprising that the results differ. sin(pi) is not zero, as it also has been rounded, and you can't represent irrational numbers exactly in a numerical form anyway. R agrees with Octave: octave:1 sin(pi) ans =

Re: [R] sin(pi)?

2007-09-03 Thread Prof Brian Ripley
On Mon, 3 Sep 2007, Nguyen Dinh Nguyen wrote: Dear all, I found something strange when calculating sin of pi value What exactly? Comments below on two guesses as to what. sin(pi) [1] 1.224606e-16 That is non-zero due to using finite-precision arithmetic. The number stored as pi is not

Re: [R] Different behavior of mtext

2007-09-03 Thread Prof Brian Ripley
On Sun, 2 Sep 2007, Sébastien wrote: Dear R Users, I am quite surprised to see that mtext gives different results when it is used with 'pairs' and with plot'. In the two following codes, it seems that the 'at' argument in mtext doesn't consider the same unit system. It is stated to be in

[R] Ask alpha cronbach and Hoyt method

2007-09-03 Thread thamrin hm
Dear all, i need help about comparing 2 alpha cronbach. How to derive W statistic. Are alpha cronbach and Hoyt's method using ANOVA identical? Thank you for your help. Regards - Luggage? GPS? Comic books? [[alternative HTML version deleted]]

[R] [R-pkgs] adehabitat version 1.7

2007-09-03 Thread Clément Calenge
Dear all, I have uploaded to CRAN the version 1.7 of the package 'adehabitat'. Significant changes are listed below: * The Brownian bridge kernel estimation algorithm has been greatly improved. It now takes more than 80% less time than the previous version. A new function liker has also been

[R] The quadprog package

2007-09-03 Thread thomas.schwander
Hi everybody, I'm using Windows XP Prof, R 2.5.1 and a Pentium 4 Processor. Now, I want to solve a quadratic optimization program (Portfolio Selection) with the quadprog package I want to minimize (\omega'%*%\Sigma%*%\omega) Subject to (1) \iota' %*% \omega = 1 (full investment)

Re: [R] Incomplete Gamma function

2007-09-03 Thread Robin Hankin
Hello Ted thanks for the comments below. You point out below some less-than-perfect aspects of some of my documentation (bizarrely, this is not the first time that this has happened. The real problem is that *other people* insist on reading the docs, when as everyone knows, the real purpose

Re: [R] by group problem

2007-09-03 Thread Petr PIKAL
Hi now I understand better what you want topN.2 - function(data,n=5) data[order(data[,3], decreasing=T),][1:n] # I presume data is data frame with 3 columns and the third is percent lapply(split(data,data$state), topN.2) Regards Petr [EMAIL PROTECTED] Cory Nissen [EMAIL PROTECTED] napsal

Re: [R] some problems with linebuffer; was: Bug?

2007-09-03 Thread Uwe Ligges
Johanna Hasmats wrote: Ok, attaching all files. You need to run it in the following order: parse.RData Korrelation.RData I have reduced this script to only include the error part. Input files are in the following order: oligo.prest.out for parse.RData to work. Produces the next

Re: [R] The quadprog package

2007-09-03 Thread Berwin A Turlach
G'day Thomas, On Mon, 3 Sep 2007 10:08:08 +0200 [EMAIL PROTECTED] wrote: What's wrong with my code? Require(quadprog) library(quadprog) ? :) Dmat-diag(1,7,7) # muss als quadratische Matrix eingegeben werden Dmat dvec-matrix(0,7,1) # muss als Spaltenvektor eingegeben werden dvec mu-0

[R] Odp: element wise opertation between a vector and a list

2007-09-03 Thread Petr PIKAL
Hi mapply(+, a, b) Regards Petr [EMAIL PROTECTED] napsal dne 03.09.2007 08:36:10: I want to try to get a result of element wise addition between a vector and a list. It can be done with for statement. In order to reducing computing time, I have tried to avoid for state. If anybody give me

[R] plotting predicted curves with log scale in lattice

2007-09-03 Thread Ken Knoblauch
Hi, I was taken off guard by the following behavior in a lattice plot. I frequently want to add a predicted curve defined at more points than in the formula expression of xyplot. There have been numerous examples of how to do this on r-help, but I still often struggle to make this work. I just

Re: [R] how to sub-sample a variable on another file coordinates

2007-09-03 Thread Paul Hiemstra
Dear Yogesh, This question seems more appropriate for the r-sig-geo mailing list (https://stat.ethz.ch/mailman/listinfo/r-sig-geo). The sampling of the netcdf files can be done by using the overlay function from the sp-package (available on CRAN). You would have to read both the netcdf file

[R] Plotting a table under a dendrogram

2007-09-03 Thread Daniel Brewer
Dear all, I have produced a dendrogram using hclust and I would like to plot it with a table of data associated with each sample aligned with the leaves of the tree. Is there a reasonable way to do this in R, or am I better lining it up in a image program. Many thanks --

[R] Legend issue with ggplot2

2007-09-03 Thread ONKELINX, Thierry
Dear useRs, I'm struggling with the new version of ggplot2. In the previous version I did something like this. But now this yield an error (object fill not found). library(ggplot2) dummy - data.frame(x = rep(1:10, 4), group = gl(4, 10)) dummy$y - dummy$x * rnorm(4)[dummy$group] + 5 *

Re: [R] NAs in indices

2007-09-03 Thread Jim Lemon
Muenchen, Robert A (Bob) wrote: Hi All, I'm fiddling with an program to read a text file containing periods that SAS uses for missing values. I know that if I had the original SAS data set instead of a text file, R would handle this conversion for me. Data frames do not allow missing

Re: [R] plotting predicted curves with log scale in lattice

2007-09-03 Thread Ken Knoblauch
Excuse me for forgetting sessionInfo (below) Ken Knoblauch knoblauch at lyon.inserm.fr writes: I was taken off guard by the following behavior in a lattice plot. I frequently want to add a predicted curve defined at more points than in the formula expression of xyplot. There have been

[R] Graphic representation of model results

2007-09-03 Thread Guillaume Brutel
Dear list members, I am facing difficulties in making a graphics that could show visually results of a model. I have tested the effects of 4 quantitative variables (Z1, Z2, Z3, Z4) on a variable Y using a weighted mixed effects GLM with weights W (using the glmmPQL function). I applied a

Re: [R] Ask alpha cronbach and Hoyt method

2007-09-03 Thread Doran, Harold
Hoyt's ANOVA and Cronbach's alpha are the same statistic. I think there is an example in Nunnally and Bernstein. I have no idea what a W statistic is. Can you explain that? -Original Message- From: [EMAIL PROTECTED] on behalf of thamrin hm Sent: Mon 9/3/2007 3:37 AM To:

[R] Graphic representation of model results

2007-09-03 Thread Guillaume Brutel
Apologies for cross-posting but I think my previous mail was in HTML (which is inadvisable for the help mailing list). Dear list members, I am facing difficulties in making a graphics that could show visually results of a model. I have tested

Re: [R] Legend issue with ggplot2

2007-09-03 Thread hadley wickham
On 9/3/07, ONKELINX, Thierry [EMAIL PROTECTED] wrote: Dear useRs, I'm struggling with the new version of ggplot2. In the previous version I did something like this. But now this yield an error (object fill not found). library(ggplot2) dummy - data.frame(x = rep(1:10, 4), group = gl(4, 10))

Re: [R] Legend issue with ggplot2

2007-09-03 Thread ONKELINX, Thierry
Thanks Hadley, I've been struggling with this all afternoon. But now it's working again. Since I'm using it in a script, the few extra lines don't bother me that much. Thierry ir. Thierry Onkelinx Instituut voor

Re: [R] plotting predicted curves with log scale in lattice

2007-09-03 Thread hadley wickham
Hi Ken, Alternatively, you could use ggplot2: install.packages(ggplot2) library(ggplot2) qplot(LL, RR, data=ds1, facets = . ~ FF) + geom_line(data=ds2) + scale_x_log10() It is very hard to get transformed scales working correctly, and it's something I had to spend a lot of time on in between

Re: [R] Legend issue with ggplot2

2007-09-03 Thread hadley wickham
Yes - all this stuff is currently rather undocumented. Hopefully that will change in the near future! Hadley On 9/3/07, ONKELINX, Thierry [EMAIL PROTECTED] wrote: Thanks Hadley, I've been struggling with this all afternoon. But now it's working again. Since I'm using it in a script, the few

[R] using temporary arrays in R

2007-09-03 Thread dxc13
useR's, Is there a way to create a temporary array (or matrix) in R to hold values, then drop or delete that temporary array from memory once I do not need it anymore? I am working with multidimensional arrays/matrices and I frequently perform multiple operations on the same matrix and rename

Re: [R] Different behavior of mtext

2007-09-03 Thread Sébastien
Ok, the problem is clear now. I did not get that 'user-coordinates' was refering to par(usr), when I read the help of mtext. If I may ask you some additional questions: - you mentioned a missing unit() call ; at which point should it be done in my code examples ? - could you give me some

Re: [R] using temporary arrays in R

2007-09-03 Thread Gabor Grothendieck
You can do it in a local, in a function or explicitly remove it. Also if you never assign it to a variable then it will be garbage collected as well # 1 local({ print(gc()) x - matrix(NA, 1000, 1000) print(gc()) }) gc() # 2 f - function() { print(gc()) x

Re: [R] Different behavior of mtext

2007-09-03 Thread Prof Brian Ripley
On Mon, 3 Sep 2007, Sébastien wrote: Ok, the problem is clear now. I did not get that 'user-coordinates' was refering to par(usr), when I read the help of mtext. If I may ask you some additional questions: - you mentioned a missing unit() call ; at which point should it be done in my code

[R] Fitting Pattern-Mixture Models

2007-09-03 Thread Abdus Sattar
Dear R-user: Do you know any R package that could be use for fitting a Pattern-Mixture model please? I would appreciate if you could suggest me a R package. Thank you very much, Sincerely, Sattar

[R] Shame on me ...

2007-09-03 Thread Ptit_Bleu
I read again R pour les débutants (for another problem) and I found the answer to my question. Sorry . Have a nice week, Ptiti Bleu. Felix Andrews wrote: x[[1]][4] On 8/31/07, Ptit_Bleu [EMAIL PROTECTED] wrote: Hi, I read the posts for 2 hours and ?list and tried many comninations but

[R] match help

2007-09-03 Thread dverzi
In my code, I would like to replace entries in t with entries from a random normal distribution. n-10 nl-round(1.5+rexp(1,rate=2) rate=2)) nl [1] 2 r-1:n s-sort(sample(r,nl)) t-match(r,s) r [1] 1 2 3 4 5 6 7 8 9 10 s [1] 3 8 t [1] NA NA 1 NA NA NA NA 2 NA NA

Re: [R] match help

2007-09-03 Thread Dimitris Rizopoulos
try this: x - c(NA, NA, 1, NA, NA, NA, NA, 2, NA, NA) na.ind - is.na(x) x[na.ind] - rnorm(sum(na.ind)) x I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven,

[R] Row-Echelon Form

2007-09-03 Thread Peter Danenberg
I was looking for an R-package that would reduce matrices to row-echelon form, but Google was not my friend; any leads? If not, I wonder if the problem could be expressed in terms of constraint satisfaction... __ R-help@stat.math.ethz.ch mailing list

[R] ADV: Support and Services for R from Random Technologies, LLC.

2007-09-03 Thread Gregory R. Warnes
The Power of Open-source R. The Confidence of Enterprise-Grade Support and Services. Hello Rusers! I am pleased to announce the immediate availability of the RStat Statistical Software System from Random Technologies, LLC. RStat couples the tremendous

Re: [R] Fitting Pattern-Mixture Models

2007-09-03 Thread Abdus Sattar
Dear R-user: Do you know any R package that could be use for fitting a Pattern-Mixture models (PMM) please? I would appreciate if you could suggest me a R package for fitting PMM. Thank you very much, Sincerely, Sattar

[R] how to compute cross correlation

2007-09-03 Thread Yogesh Tiwari
Hello R Users, How to compute cross correlation between two time series. Data is in ASCII format. I am using R on windows. Many thanks, Regards, Yogesh [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list

[R] Derivative of a Function Expression

2007-09-03 Thread Rory Winston
Hi I am currently (for pedagogical purposes) writing a simple numerical analysis library in R. I have come unstuck when writing a simple Newton-Raphson implementation, that looks like this: f - function(x) { 2*cos(x)^2 + 3*sin(x) + 0.5 } root - newton(f, tol=0.0001, N=20, a=1) My issue is

Re: [R] Derivative of a Function Expression

2007-09-03 Thread Alberto Monteiro
Rory Winston wrote: I am currently (for pedagogical purposes) writing a simple numerical analysis library in R. I have come unstuck when writing a simple Newton-Raphson implementation, that looks like this: f - function(x) { 2*cos(x)^2 + 3*sin(x) + 0.5 } root - newton(f, tol=0.0001,

Re: [R] Derivative of a Function Expression

2007-09-03 Thread Gabor Grothendieck
The Ryacas package can do that (but the function must be one line and it can't have brace brackets). The first yacas call below registers f with yacas, then we set up a function to act as a template to hold the derivative and then we set its body calling yacas again to take the derivative.

Re: [R] Derivative of a Function Expression

2007-09-03 Thread Gabor Grothendieck
Actually in thinking about this its pretty easy to do it without Ryacas too: Df - f body(Df) - deriv(body(f), x) Df On 9/3/07, Gabor Grothendieck [EMAIL PROTECTED] wrote: The Ryacas package can do that (but the function must be one line and it can't have brace brackets). The first yacas call

Re: [R] Derivative of a Function Expression

2007-09-03 Thread Alberto Vieira Ferreira Monteiro
Gabor Grothendieck wrote: Actually in thinking about this its pretty easy to do it without Ryacas too: Df - f body(Df) - deriv(body(f), x) Df This is weird. f - function(x) { x^2 + 2*x+1 } Df - f body(Df) - deriv(body(f), x) # error Also: f - function(x) x^2 + 2 * x + 1 Df - f body(Df)

Re: [R] Derivative of a Function Expression

2007-09-03 Thread Gabor Grothendieck
The problem is that brace brackets are not in the derivatives table. Make sure you don't have any. On 9/3/07, Alberto Vieira Ferreira Monteiro [EMAIL PROTECTED] wrote: Gabor Grothendieck wrote: Actually in thinking about this its pretty easy to do it without Ryacas too: Df - f

Re: [R] Derivative of a Function Expression

2007-09-03 Thread Ted Harding
On 03-Sep-07 21:45:40, Alberto Monteiro wrote: Rory Winston wrote: I am currently (for pedagogical purposes) writing a simple numerical analysis library in R. I have come unstuck when writing a simple Newton-Raphson implementation, that looks like this: f - function(x) { 2*cos(x)^2 +

Re: [R] element wise opertation between a vector and a list

2007-09-03 Thread Moshe Olshansky
Hi, Getting your e is not a problem: a- list(c(1,3),c(1,2),c(2,3)) b-c(10,20,30) aa-matrix(unlist(a),nrow=2) ee-aa+rbind(b,b) e-apply(ee,2,sum) e [1] 24 43 65 But this will not work if different list members have different number of elements. --- Yongwan Chun [EMAIL PROTECTED] wrote:

Re: [R] plotting predicted curves with log scale in lattice

2007-09-03 Thread Deepayan Sarkar
On 9/3/07, Ken Knoblauch [EMAIL PROTECTED] wrote: Hi, I was taken off guard by the following behavior in a lattice plot. I frequently want to add a predicted curve defined at more points than in the formula expression of xyplot. There have been numerous examples of how to do this on r-help,

Re: [R] Derivative of a Function Expression

2007-09-03 Thread Gabor Grothendieck
One improvement. This returns a function directly without having to create a template and filling in its body: deriv(body(f), x, func = TRUE) On 9/3/07, Gabor Grothendieck [EMAIL PROTECTED] wrote: The problem is that brace brackets are not in the derivatives table. Make sure you don't have

Re: [R] how to compute cross correlation

2007-09-03 Thread Moshe Olshansky
The simlest answer is that X and Y are two vectors of length n then (un-normalized) cross correlation between X and Y is sum(i=1 to n) {X(i)-Xbar)*(Y(i)-Ybar)} where Xbar and Ybar are the means of X and Y respectively. You may need something different, so could you be more specific? What do you

Re: [R] Derivative of a Function Expression

2007-09-03 Thread Gabor Grothendieck
And if f has brace brackets surrounding the body then do this: f - function(x) { x*x } deriv(body(f)[[2]], x, func = TRUE) If you are writing a general function you can do this: e - if (identical(body(f)[[1]], as.name({))) body(f)[[2]] else body(f) deriv(e, x, func = TRUE) On 9/3/07, Gabor

Re: [R] The quadprog package

2007-09-03 Thread Moshe Olshansky
Hi Thomas, On my computer the solution is (0,0,1,0,0,0,0) (within machine accuracy) and it satisfies the constraints. --- [EMAIL PROTECTED] wrote: Hi everybody, I'm using Windows XP Prof, R 2.5.1 and a Pentium 4 Processor. Now, I want to solve a quadratic optimization program (Portfolio

Re: [R] Different behavior of mtext

2007-09-03 Thread Sébastien
Thanks for the information on gridBase, I could solve my problem using the 'baseViewports' function and by replacing mtext by grid.text (with coordinates adjustments). Sebastien Prof Brian Ripley a écrit : On Mon, 3 Sep 2007, Sébastien wrote: Ok, the problem is clear now. I did not get that

Re: [R] Row-Echelon Form

2007-09-03 Thread John Fox
Dear Peter, Some time ago, I posted a function RREF to r-help that computes the reduced row-echelon form of a matrix. Just last week, Scott Hyde posted a revised version of this function to r-help (see https://stat.ethz.ch/pipermail/r-help/2007-September/139923.html). My original function didn't

Re: [R] Package installation

2007-09-03 Thread Matias Bordese
We are working in a new release that would solve the problem mentioned; in the current source tarball available it could be manage as Uwe said, adding the line in the DESCRIPTION file: ZipData: no By the way, besides the RTools needed to compile any package in Windows, you will need to install

[R] Efficient sampling from a discrete distribution in R

2007-09-03 Thread Issac Trotts
Hello r-help, As far as I've seen, there is no function in R dedicated to sampling from a discrete distribution with a specified mass function. The standard library doesn't come with anything called rdiscrete or rpmf, and I can't find any such thing on the cheat sheet or in the Probability

Re: [R] Derivative of a Function Expression

2007-09-03 Thread Rory Winston
Hi guys Thanks for all the fantastic suggestions! I didnt realise you could extract the body of a function in that manner. It looks like R always has many ways to solve a particular problem. Cheers Rory On 9/4/07, Gabor Grothendieck [EMAIL PROTECTED] wrote: And if f has brace brackets

Re: [R] Efficient sampling from a discrete distribution in R

2007-09-03 Thread Prof Brian Ripley
On Mon, 3 Sep 2007, Issac Trotts wrote: Hello r-help, As far as I've seen, there is no function in R dedicated to sampling from a discrete distribution with a specified mass function. The standard library doesn't come with anything called rdiscrete or rpmf, and I can't find any such thing

Re: [R] Efficient sampling from a discrete distribution in R

2007-09-03 Thread Issac Trotts
Thanks to you and Burwin for helping. My simulation seems faster now (btw, is there some easy way to time things in R?) but not as fast as I was hoping. Here's the top level function. Any ideas on how to make it faster? # Sample from a Chinese Restaurant Process # # size: number of samples to

Re: [R] Embedding Audio Files in Interactive Graphs

2007-09-03 Thread Sam Ferguson
Thanks for your reply Bruno. No - as I said, I know how to do that - the movie15 and the multimedia package are basically the same, and it is relatively straightforward to get an audio file into a pdf with them. However, real interactivity is not easily achieved in latex IMO (as it's not