[R] About filled.contour function
Dear R-projects users I would like like to ask if there is any way to produce a multipanel plot with the filled.contour function. In the help information of filled contour it is said that this function is restricted to a full page display. With kind regards Prodromos Zanis -- Dr. Prodromos Zanis Centre for Atmospheric Physics and Climatology Academy of Athens 3rd September 131, Athens 11251, Greece Tel. +30 210 8832048 Fax: +30 210 8832048 e-mail: [EMAIL PROTECTED] Web address: http://users.auth.gr/~zanis/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Inverting a large Matrix (14000 x 14000)
> "Cal" == Cal Stats <[EMAIL PROTECTED]> > on Sun, 25 Jun 2006 01:14:34 -0700 (PDT) writes: Cal> Hi.. I have to invert a 15000 x 15000 matrix Cal> (generalized inverse). I do run the process on a fairly Cal> powerful computer. but still complains indufficient Cal> memory. Cal> Is there a way one can invert a large matrix in some Cal> other efficient manner. Is the matrix sparse, i.e., has most of its entries == 0 ? If yes, then there are more efficient ways, notably in packages 'SparseM' and 'Matrix'. Cal> Thanks Harsh __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] About filled.contour function
Prodromos Zanis wrote: > Dear R-projects users > > I would like like to ask if there is any way to produce a multipanel plot > with the filled.contour function. In the help information of filled > contour it is said that this function is restricted to a full page > display. > > With kind regards > > Prodromos Zanis > > > > `filled.contour' sets up a 2-by-1 grid (for colormap and image) using the `layout' function, hence a prior setup of a multipanel layout would be (and is) destroyed by the `filled.contour' call. you might edit a copy of `filled contour' to modify the `layout' call (e.g. to set up a 2-by-2 grid where only the upper row is used by the plots generated in filled contour). I tried this very shortly before answering but it seems that only 'within' the filled.contour copy one has access to the other subplots, after return from the function plot focus is again in subplot no. one --no time to check this further. in any case along this line one should be able to enforce multiple subplots where 2 of them are used by the modified `filled.contour' joerg __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] problem with "code/documentation mismatch"
Just an idea: how about using the \usage for the formal syntax, and \synopsis for the "user syntax", i.e. x/y ? Not sure it will work, but it might be worth a try... :-) -- Bjørn-Helge Mevik __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] PowerPoint - eps not suitable
On Fri, Jun 23, 2006 at 01:43:54PM -0500, Marc Schwartz (via MN) wrote: > On Fri, 2006-06-23 at 14:02 -0400, Michael H. Prager wrote: > > Previous posters have argued for EPS files as a desirable transfer > > format for quality reasons. This is of course true when the output is > > through a Postscript device. > > > > However, the original poster is making presentations with PowerPoint. > > Those essentially are projected from the screen -- and screens of > > Windows PCs are NOT Postscript devices. The version of PowerPoint I > > have will display a bitmapped, low-resolution preview when EPS is > > imported, and that is what will be projected. It is passable, but much > > better can be done! > > > > In this application, I have had best results using cut and paste or the > > Windows metafile format, both of which (as others have said) give > > scalable vector graphics. When quirks of Windows metafile arise (as > > they can do, especially when fonts differ between PCs), I have had good > > results with PNG for line art and JPG for other art. > > > > Mike > > Just so that it is covered (though this has been noted in other > threads), even in this situation, one can still use EPS files embedded > in PowerPoint (or Impress) presentations. Just to cover yet another possible route, I've in the past used ghostscript to produce high resolution (or, more generally, whatever resolution was required) raster images from PostScript by something like gs -r150x150 -sDEVICE=bmp256 -sOutputFile=x.bmp -dNOPAUSE myfile.ps -c quit Apologies if this has been mentioned in this thread already. Best regards, Jan -- +- Jan T. Kim ---+ | email: [EMAIL PROTECTED] | | WWW: http://www.cmp.uea.ac.uk/people/jtk | *-=< hierarchical systems are for files, not for humans >=-* __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] getting the smoother matrix from smooth.spline
> "Gregory" == Gregory Gentlemen <[EMAIL PROTECTED]> > on Sat, 24 Jun 2006 14:41:37 -0400 (EDT) writes: Gregory> Can anyone tell me the trick for obtaining the Gregory> smoother matrix from smooth.spline when there are Gregory> non-unique values for x. I have the following code Gregory> but, of course, it only works when all values of x Gregory> are unique. >>## get the smoother matrix (x having unique values >>smooth.matrix = function(x, df){ >> n = length(x); >> A = matrix(0, n, n); >> for(i in 1:n){ >>y = rep(0, n); y[i]=1; >>yi = smooth.spline(x, y, df=df)$y; >>A[,i]= yi; >> } >> (A+t(A))/2; >>} { All the extraneous ";" at the end of lines make the above unncessarily ugly (and potentially even slightly inefficient).} Package 'sfsmisc' has had a function hatMat() which returns the hat matrix aka smoother matrix, in a slightly more general way -- you can use it also for other smoothers, see the examples in help(hatMat). The smoother defaults to smooth.spline(), so you can directly use it, e.g., hatMat(x, df=5) Why do you think your code or hatMat() would not work for non-unique x-values? Gregory> Thanks for any assistance, Gregory> Gregory Gregory> - Gregory> [[alternative HTML version deleted]] ^^^ [please do read the posting guide, and hence get rid of the line above ! ] Gregory> __ Gregory> R-help@stat.math.ethz.ch mailing list Gregory> https://stat.ethz.ch/mailman/listinfo/r-help Gregory> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] PowerPoint - eps not suitable
On 6/26/06, Jan T. Kim <[EMAIL PROTECTED]> wrote: > On Fri, Jun 23, 2006 at 01:43:54PM -0500, Marc Schwartz (via MN) wrote: > > On Fri, 2006-06-23 at 14:02 -0400, Michael H. Prager wrote: > > > Previous posters have argued for EPS files as a desirable transfer > > > format for quality reasons. This is of course true when the output is > > > through a Postscript device. > > > > > > However, the original poster is making presentations with PowerPoint. > > > Those essentially are projected from the screen -- and screens of > > > Windows PCs are NOT Postscript devices. The version of PowerPoint I > > > have will display a bitmapped, low-resolution preview when EPS is > > > imported, and that is what will be projected. It is passable, but much > > > better can be done! > > > > > > In this application, I have had best results using cut and paste or the > > > Windows metafile format, both of which (as others have said) give > > > scalable vector graphics. When quirks of Windows metafile arise (as > > > they can do, especially when fonts differ between PCs), I have had good > > > results with PNG for line art and JPG for other art. > > > > > > Mike > > > > Just so that it is covered (though this has been noted in other > > threads), even in this situation, one can still use EPS files embedded > > in PowerPoint (or Impress) presentations. > > Just to cover yet another possible route, I've in the past used ghostscript > to produce high resolution (or, more generally, whatever resolution was > required) raster images from PostScript by something like > >gs -r150x150 -sDEVICE=bmp256 -sOutputFile=x.bmp -dNOPAUSE myfile.ps -c quit > > Apologies if this has been mentioned in this thread already. > > Best regards, Jan > -- > +- Jan T. Kim ---+ > | email: [EMAIL PROTECTED] | > | WWW: http://www.cmp.uea.ac.uk/people/jtk | > *-=< hierarchical systems are for files, not for humans >=-* Useful in this regard on Windows XP, is withgs.bat in batchfiles. It will locate ghostscript on your system (using the registry), temporarily add it to your path and then run its argument as a command. withgs.bat can be placed anywhere in your path. Google for: CRAN batchfiles __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Function with upper/lower bound, shift,slope,curvature
Dear R Users, I am looking for a function to use within optim s.t. - f(x,a,b,c,d,e) where I am searching over parameter values a,b,c,d,e - a is the lower bound (typically 1) - b is the upper bound (typically 0) - c,d,e give the function a shift, slope and curvature between a and b Any good candidates for a non-linear optimisation problem known, either already built into R, or otherwise. A sigmoid sort of gets half there, but I need some more control over the curvature and upper/lower bounds of the function. sigm<-function(x,a,t) 0.5*(1+(1-exp((x-a)/t))/(1+exp((x-a)/t))) Thanks in advance, Tolga __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] assign / environment side effect on R 2.4.0
Please do study the posting guide, as there is no `R 2.4.0'. This seems to be related to the NEWS item o [[ on a list does not duplicate the extracted element unless necessary. (It did not duplicate in other cases, e.g. a pairlist.) Now in so far as I can follow it, in your example [[ behaves in the same way as $ always did (which is what informed people would expect). R-help is not the place to discuss unreleased versions of R, nor for questions about code development. (Did I mention studying the posting guide?) On Fri, 23 Jun 2006, Thomas Petzoldt wrote: > Sorry, > > the posted example had the side effect on all platforms (correctly: R > 2.2.1/Windows, 2.3.1/Linux, 2.4.0/Windows), but in the following > corrected example the behavior of 2.4.0 differs from the older versions. > > The only difference between the "wrong" and the "new" example is > L[["test"]] vs. L$test in the assign. > > Thomas P. > > > envfun <- function(L) { > # L <- as.list(unlist(L)) > p <- parent.frame() > assign("test", L[["test"]], p) ## [["test"]] instead of $test > environment(p[["test"]]) <- p > } > > > solver <- function(L) { > envfun(L) > # some other stuff > } > > L <- list(test = function() 1 + 2) > > e1 <- environment(L$test) > solver(L) > e2 <- environment(L$test) > > print(e1) > print(e2) > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] NLS and fitting of x-values?
I collected eggs laid by Springtails everyday over 28 days after swich to isotopically enriched diet. The eggs were pooled at day 7, 14, and 28 (+ day 0 = initial value) and analyzed for isotopes. After the diet switch the isotopic values of the adults and eggs change towards those of the new diet. Here are the d13C values (y) of the eggs: x y 0 -22.2 0 -22.2 0 -22.2 0 -22.0 7 486.9 7 498.6 7 489.6 14 820.9 14 817.4 28 895.6 28 900.7 28 890.6 28 885.8 The y values represent the mean of the sampling period. The dataset is very small but previous experiments have shown that a exponential asymptotic model can be used for this kind of situations. How do I fit a model to these pooled values? The y values can be regarded as the mean of the given sampling period. My first guess is that the x values should be in the middle of the collection period. I call these x-values xi: xi=c(rep(0,4),rep(3.5,3),rep(10.5,2),rep(21,4)) If I fit them to a nonlinear regression model via least squares (NLS) I get the parameters: Value Std. Error t value a 900.386000 3.7839900 237.9460 b 916.63 29.3987000 31.1792 c 0.230811 0.0102677 22.4792 How do I procede from here? I should probably use a maximum likelihood estimate to estimate the fitted xi? Any help would be greatly appreciated. --- Thomas Larsen, PhD student Department of Terrestrial Ecology National Environmental Research Institute Vejlsøvej 25, P.O. Box 314, DK-8600 Silkeborg Phone +45 8920 1572; Fax +45 8920 1414; __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] NLS and fitting of x-values?
"Larsen, Thomas" <[EMAIL PROTECTED]> writes: > I collected eggs laid by Springtails everyday over 28 days after swich to > isotopically enriched diet. The eggs were pooled at day 7, 14, and 28 (+ day > 0 = initial value) and analyzed for isotopes. After the diet switch the > isotopic values of the adults and eggs change towards those of the new diet. > Here are the d13C values (y) of the eggs: > > x y > 0 -22.2 > 0 -22.2 > 0 -22.2 > 0 -22.0 > 7 486.9 > 7 498.6 > 7 489.6 > 14 820.9 > 14 817.4 > 28 895.6 > 28 900.7 > 28 890.6 > 28 885.8 > > The y values represent the mean of the sampling period. > > The dataset is very small but previous experiments have shown that a > exponential asymptotic model can be used for this kind of situations. > > How do I fit a model to these pooled values? The y values can be regarded as > the mean of the given sampling period. > > My first guess is that the x values should be in the middle of the collection > period. I call these x-values xi: > xi=c(rep(0,4),rep(3.5,3),rep(10.5,2),rep(21,4)) > > If I fit them to a nonlinear regression model via least squares (NLS) I get > the parameters: >Value Std. Error t value > a 900.386000 3.7839900 237.9460 > b 916.63 29.3987000 31.1792 > c 0.230811 0.0102677 22.4792 > > How do I procede from here? I should probably use a maximum likelihood > estimate to estimate the fitted xi? > Any help would be greatly appreciated. My take is that you should just have your expected y values (which in this case are also the eggs-values, but never mind...) modeled as what they are, namely an integral under the curve between x[i-1] and x[i], or for practical purposes take the sum over days (say) 15 to 28 and divide by 14. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] reshaping data.frame question
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dear R-helpers, my data.frame is of the form x <- data.frame( f=gl(4,3), X=rep(0:2,4), p=c(.1,.2,.3)) x f X p 1 1 0 0.1 2 1 1 0.2 3 1 2 0.3 4 2 0 0.1 5 2 1 0.2 6 2 2 0.3 7 3 0 0.1 8 3 1 0.2 9 3 2 0.3 10 4 0 0.1 11 4 1 0.2 12 4 2 0.3 which tabulates some values p(X) for several factors f. Now I want to put it in "wide" format, so that factor levels appear as column heads. Note also that X starts from zero. It would be nice if I could simply access p_f[X==0] as f[0]. How can I possibly do that? (The resilting object does not have to be a data.frame. As there are only numeric values, also a matrix would do.) I tried the following y<-unstack(x,form=p~f) row.names(y) <- 0:2 y X1 X2 X3 X4 0 0.1 0.1 0.1 0.1 1 0.2 0.2 0.2 0.2 2 0.3 0.3 0.3 0.3 Now, how to access X3[0], say? Maybe reshape would be the right tool, but I could not figure it out. I appreciate your help. Thanks! -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.2 (GNU/Linux) iD8DBQFEn9G2XjamRUP82DkRAorGAJ9JirG7WtNJLWRQkJvgW0zTFHTYagCgvONw IC4jgoxE2+CsOmmogv5dzF0= =24Kj -END PGP SIGNATURE- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] New version of plotrix
Hi folks, I usually don't do version announcements, but several people have requested things that are in this version (2.1). Prominent among these are that soil.texture has inflated into yet another general triangle plot function (triax.plot), the dreaded shadow effect has materialized, pie3D has lost a couple of bugs and by a sequence of improbable coincidences another wind rose plot is airborne, this one in the Australian style. As always, please tell me where I've blown it, for your comments have often gotten me on a better tack. Jim __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lmer and mixed effects logistic regression
On Fri, 2006-06-23 at 21:38 -0700, Spencer Graves wrote: > Permit me to try to repeat what I said earlier a little more clearly: > When the outcomes are constant for each subject, either all 0's or all > 1's, the maximum likelihood estimate of the between-subject variance in > Inf. Any software that returns a different answer is wrong. This is NOT > a criticism of 'lmer' or SAS NLMIXED: This is a sufficiently rare, > extreme case that the software does not test for it and doesn't handle > it well when it occurs. Adding other explanatory variables to the model > only makes this problem worse, because anything that will produce > complete separation for each subject will produce this kind of > instability. > >Consider the following: > > library(lme4) > DF <- data.frame(y=c(0,0, 0,1, 1,1), > Subj=rep(letters[1:3], each=2), > x=rep(c(-1, 1), 3)) > fit1 <- lmer(y~1+(1|Subj), data=DF, family=binomial) > > # 'lmer' works fine here, because the outcomes from > # 1 of the 3 subjects is not constant. > > > fit.x <- lmer(y~x+(1|Subj), data=DF, family=binomial) > Warning message: > IRLS iterations for PQL did not converge > > The addition of 'x' to the model now allows complete separation for > each subject. We see this in the result: > > Generalized linear mixed model fit using PQL > > Random effects: > Groups NameVariance Std.Dev. > Subj (Intercept) 3.5357e+20 1.8803e+10 > number of obs: 6, groups: Subj, 3 > > Estimated scale (compare to 1) 9.9414e-09 > > Fixed effects: > Estimate Std. Errorz value Pr(>|z|) > (Intercept) -5.4172e-05 1.0856e+10 -4.99e-151 > x8.6474e+01 2.7397e+07 3.1563e-061 > > Note that the subject variance is 3.5e20, the estimate for x is 86 > wit a standard error of 2.7e7. All three of these numbers are reaching > for Inf; lmer quit before it got there. > > Does this make any sense, or are we still misunderstanding one > another? > > Hope this helps. > Spencer Graves > Yes, thanks, it's clear. I had created a new data set that has each subject with just one observation and randomly sampled one observation from each subject with two observations (they are right and left eyes). I'm not sure why lmer gives small estimated variances for the random effects when it should be infinite. I ran NLMIXED on the original data set with several explanatory factors and the variance component was in the thousands. I guess the moral is before you do any computations you have to make sure the procedure makes sense for the data. Rick B. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] reshaping data.frame question
You need to specify the row/column name as character: > y X1 X2 X3 X4 0 0.1 0.1 0.1 0.1 1 0.2 0.2 0.2 0.2 2 0.3 0.3 0.3 0.3 > y[,'X3'] [1] 0.1 0.2 0.3 > y['0','X3'] [1] 0.1 On 6/26/06, Matthias Braeunig <[EMAIL PROTECTED]> wrote: > > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Dear R-helpers, > > my data.frame is of the form > > x <- data.frame( f=gl(4,3), X=rep(0:2,4), p=c(.1,.2,.3)) > x > f X p > 1 1 0 0.1 > 2 1 1 0.2 > 3 1 2 0.3 > 4 2 0 0.1 > 5 2 1 0.2 > 6 2 2 0.3 > 7 3 0 0.1 > 8 3 1 0.2 > 9 3 2 0.3 > 10 4 0 0.1 > 11 4 1 0.2 > 12 4 2 0.3 > > which tabulates some values p(X) for several factors f. > > Now I want to put it in "wide" format, so that factor levels appear as > column heads. Note also that X starts from zero. It would be nice if I > could simply access p_f[X==0] as f[0]. How can I possibly do that? > > (The resilting object does not have to be a data.frame. As there are > only numeric values, also a matrix would do.) > > I tried the following > > y<-unstack(x,form=p~f) > row.names(y) <- 0:2 > y > X1 X2 X3 X4 > 0 0.1 0.1 0.1 0.1 > 1 0.2 0.2 0.2 0.2 > 2 0.3 0.3 0.3 0.3 > > Now, how to access X3[0], say? > > Maybe reshape would be the right tool, but I could not figure it out. > > I appreciate your help. Thanks! > > > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.2.2 (GNU/Linux) > > iD8DBQFEn9G2XjamRUP82DkRAorGAJ9JirG7WtNJLWRQkJvgW0zTFHTYagCgvONw > IC4jgoxE2+CsOmmogv5dzF0= > =24Kj > -END PGP SIGNATURE- > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > -- Jim Holtman Cincinnati, OH +1 513 646 9390 (Cell) +1 513 247 0281 (Home) What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] converting to time series object : ts - package:stats
Hi, I am trying to convert a dataset (dataframe) into time series object using ts function in stats package. My dataset is as follows: >df [1] 11.08 7.08 7.08 6.08 6.08 6.08 23.08 32.08 8.08 11.08 6.08 13.08 13.83 16.83 19.83 8.83 20.83 17.83 [19] 9.83 20.83 10.83 12.83 15.83 11.83 I converted this into time series object as follows >tsdata <- ts((df),frequency = 12, start = c(1999, 1)) The resulting time series is as follows: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 1999 2 15 15 14 14 14 12 13 16 2 14 5 2000 6 8 10 17 11 9 18 11 1 4 7 3 I am unable to understand why the values of df and tsdata does not match. I looked at ts function and I couldn't find any data transformation. Am I missing something here? Any pointers would be of great help. Thanks in advance. Sachin - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Patch for rgl with gcc 4.0 in R 2.3.0 on OS X
Hi, I recently had a problem installing the rgl package on OS X and put together a simple patch. The patched package is available here: http://jinome.stanford.edu/files/rgl_0.66-patched_for_gcc4.tar.gz It can be installed with "R CMD INSTALL rgl_0.66-patched_for_gcc4.tar.gz" as normal at the command line. Also -- as of right now rgl is not in the repository of version 2.3 packages (or at least did not come up when I ran new.packages() at the R prompt). I'm not sure if this build error was the problem, but if so this version now works perfectly. For those who are interested, I have included details on what exactly went wrong and the fix: 1) What went wrong -- here is the output of the initial build attempt. The install fails because of an invalid integer conversion, which I eventually figured out was due to gcc-4 flagging it as an error, whereas gcc-3 and earlier would have called it a warning. [root:/root/downloads/rgl_patch]$R CMD INSTALL rgl_0.66.tar.gz * Installing *source* package 'rgl' ... checking for libpng-config... yes configure: using libpng-config configure: using libpng dynamic linkage configure: creating ./config.status config.status: creating src/Makevars ** libs ** arch - i386 g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 -march=pentium-m -mtune=prescott -c BBoxDeco.cpp -o BBoxDeco.o g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 -march=pentium-m -mtune=prescott -c Background.cpp -o Background.o g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 -march=pentium-m -mtune=prescott -c Color.cpp -o Color.o g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 -march=pentium-m -mtune=prescott -c Disposable.cpp -o Disposable.o g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 -march=pentium-m -mtune=prescott -c FaceSet.cpp -o FaceSet.o g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 -march=pentium-m -mtune=prescott -c Light.cpp -o Light.o g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 -march=pentium-m -mtune=prescott -c LineSet.cpp -o LineSet.o g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 -march=pentium-m -mtune=prescott -c LineStripSet.cpp -o LineStripSet.o g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 -march=pentium-m -mtune=prescott -c Material.cpp -o Material.o g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 -march=pentium-m -mtune=prescott -c PointSet.cpp -o PointSet.o g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 -march=pentium-m -mtune=prescott -c PrimitiveSet.cpp -o PrimitiveSet.o g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/incl
Re: [R] Patch for rgl with gcc 4.0 in R 2.3.0 on OS X
I think this has already been fixed. The rgl repository had a disk crash and is being restored today, but you can see a recent build on my web page, http://www.stats.uwo.ca/faculty/murdoch/software/ We are planning a new release very soon; the disk crash is a bit of a nuisance, though. Duncan Murdoch On 6/26/2006 9:08 AM, Balaji S. Srinivasan wrote: > Hi, > > I recently had a problem installing the rgl package on OS X and put together > a simple patch. The patched package is available here: > > http://jinome.stanford.edu/files/rgl_0.66-patched_for_gcc4.tar.gz > > It can be installed with "R CMD INSTALL rgl_0.66-patched_for_gcc4.tar.gz" as > normal at the command line. > > Also -- as of right now rgl is not in the repository of version 2.3 packages > (or at least did not come up when I ran new.packages() at the R prompt). I'm > not sure if this build error was the problem, but if so this > version now works perfectly. For those who are interested, I have included > details on what exactly went wrong and the fix: > > 1) What went wrong -- here is the output of the initial build attempt. The > install fails because of an invalid integer conversion, which I eventually > figured out was > due to gcc-4 flagging it as an error, whereas gcc-3 and earlier would have > called it a warning. > > [root:/root/downloads/rgl_patch]$R CMD INSTALL rgl_0.66.tar.gz > * Installing *source* package 'rgl' ... > checking for libpng-config... yes > configure: using libpng-config > configure: using libpng dynamic linkage > configure: creating ./config.status > config.status: creating src/Makevars > ** libs > ** arch - i386 > g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON > -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H > -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 > -march=pentium-m -mtune=prescott -c BBoxDeco.cpp -o BBoxDeco.o > g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON > -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H > -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 > -march=pentium-m -mtune=prescott -c Background.cpp -o Background.o > g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON > -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H > -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 > -march=pentium-m -mtune=prescott -c Color.cpp -o Color.o > g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON > -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H > -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 > -march=pentium-m -mtune=prescott -c Disposable.cpp -o Disposable.o > g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON > -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H > -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 > -march=pentium-m -mtune=prescott -c FaceSet.cpp -o FaceSet.o > g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON > -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H > -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 > -march=pentium-m -mtune=prescott -c Light.cpp -o Light.o > g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON > -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H > -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 > -march=pentium-m -mtune=prescott -c LineSet.cpp -o LineSet.o > g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON > -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H > -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 > -march=pentium-m -mtune=prescott -c LineStripSet.cpp -o LineStripSet.o > g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON > -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H > -I/opt/local/include/libpng12 -msse3 -fPIC -fno-common -g -O2 > -march=pentium-m -mtune=prescott -c Material.cpp -o Material.o > g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON > -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H > -I/opt/local/include
Re: [R] converting to time series object : ts - package:stats
On Mon, 26 Jun 2006, Sachin J wrote: > I am trying to convert a dataset (dataframe) into time series object > using ts function in stats package. My dataset is as follows: > > >df > [1] 11.08 7.08 7.08 6.08 6.08 6.08 23.08 32.08 8.08 11.08 6.08 13.08 > 13.83 16.83 19.83 8.83 20.83 17.83 > [19] 9.83 20.83 10.83 12.83 15.83 11.83 No data frame will print like that, so it seems that your description and printout do not match. > I converted this into time series object as follows > > >tsdata <- ts((df),frequency = 12, start = c(1999, 1)) >From the help page for ts: data: a numeric vector or matrix of the observed time-series values. A data frame will be coerced to a numeric matrix via 'data.matrix'. I suspect you have a single-column data frame with a factor column. Look up what data.matrix does for factors. > The resulting time series is as follows: > > Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec > 1999 2 15 15 14 14 14 12 13 16 2 14 5 > 2000 6 8 10 17 11 9 18 11 1 4 7 3 > > I am unable to understand why the values of df and tsdata does not > match. I looked at ts function and I couldn't find any data > transformation. Am I missing something here? Any pointers would be of > great help. > > Thanks in advance. > > Sachin > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] converting to time series object : ts - package:stats
On Mon, 26 Jun 2006, Sachin J wrote: > Hi, > > I am trying to convert a dataset (dataframe) into time series object > using ts function in stats package. My dataset is as follows: > > >df > [1] 11.08 7.08 7.08 6.08 6.08 6.08 23.08 32.08 8.08 11.08 6.08 13.08 > 13.83 16.83 19.83 8.83 20.83 17.83 > [19] 9.83 20.83 10.83 12.83 15.83 11.83 Please provide a reproducible example. You just showed us the print output for an object, claiming that it is an object of class "data.frame" which is rather unlikely given the print output. > I converted this into time series object as follows > > >tsdata <- ts((df),frequency = 12, start = c(1999, 1)) which produces the right result for me if `df' is a vector or a data.frame: df <- c(11.08, 7.08, 7.08, 6.08, 6.08, 6.08, 23.08, 32.08, 8.08, 11.08, 6.08, 13.08, 13.83, 16.83, 19.83, 8.83, 20.83, 17.83, 9.83, 20.83, 10.83, 12.83, 15.83, 11.83) ts(df, frequency = 12, start = c(1999, 1)) ts(as.data.frame(df), frequency = 12, start = c(1999, 1)) > The resulting time series is as follows: > >Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec > 1999 2 15 15 14 14 14 12 13 16 2 14 5 > 2000 6 8 10 17 11 9 18 11 1 4 7 3 > > I am unable to understand why the values of df and tsdata does not match. So are we because you didn't really tell us enough about df... Best, Z > I looked at ts function and I couldn't find any data transformation. Am > I missing something here? Any pointers would be of great help. > > Thanks in advance. > > Sachin > > > - > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Puzzled with contour()
Folks, The contour() function wants x and y to be in increasing order. I have a situation where I have a grid in x and y, and associated z values, which looks like this: x y z [1,] 0.00 20 1.000 [2,] 0.00 30 1.000 [3,] 0.00 40 1.000 [4,] 0.00 50 1.000 [5,] 0.00 60 1.000 [6,] 0.00 70 1.000 [7,] 0.00 80 0.000 [8,] 0.00 90 0.000 [9,] 0.00 100 0.000 [10,] 0.00 110 0.000 [11,] 0.00 120 0.000 [12,] 0.00 130 0.000 [13,] 0.00 140 0.000 [14,] 0.00 150 0.000 [15,] 0.00 160 0.000 [16,] 0.00 170 0.000 [17,] 0.00 180 0.000 [18,] 0.00 190 0.000 [19,] 0.00 200 0.000 [20,] 0.05 20 1.000 [21,] 0.05 30 1.000 [22,] 0.05 40 1.000 [23,] 0.05 50 1.000 [24,] 0.05 60 0.998 [25,] 0.05 70 0.124 [26,] 0.05 80 0.000 [27,] 0.05 90 0.000 [28,] 0.05 100 0.000 [29,] 0.05 110 0.000 [30,] 0.05 120 0.000 [31,] 0.05 130 0.000 [32,] 0.05 140 0.000 [33,] 0.05 150 0.000 [34,] 0.05 160 0.000 [35,] 0.05 170 0.000 [36,] 0.05 180 0.000 [37,] 0.05 190 0.000 [38,] 0.05 200 0.000 [39,] 0.10 20 1.000 [40,] 0.10 30 1.000 This looks like a nice case where both x and y are in increasing order. But contour() gets unhappy saying that he wants x and y in increasing order. Gnuplot generates pretty 3d pictures from such data, where you are standing above a surface and looking down at it. How does one do that in R? Any help will be most appreciated. A dput() of my data object is : structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 20, 30,
Re: [R] converting to time series object : ts - package:stats
Hi Achim, I did the following: >df <- read.csv("C:/data.csv", header=TRUE,sep=",",na.strings="NA", dec=",", strip.white=TRUE) Note: data.csv has 10 (V1...V10) columns. >df[1] V1 111.08 2 7.08 3 7.08 4 6.08 5 6.08 6 6.08 723.08 832.08 9 8.08 10 11.08 116.08 12 13.08 13 13.83 14 16.83 15 19.83 168.83 17 20.83 18 17.83 199.83 20 20.83 21 10.83 22 12.83 23 15.83 24 11.83 >tsdata <- ts((df[1]),frequency = 12, start = c(2005, 1)) The resulting time series is different from the df. I don't know why? I think I am doing something silly. TIA Sachin Achim Zeileis <[EMAIL PROTECTED]> wrote: On Mon, 26 Jun 2006, Sachin J wrote: > Hi, > > I am trying to convert a dataset (dataframe) into time series object > using ts function in stats package. My dataset is as follows: > > >df > [1] 11.08 7.08 7.08 6.08 6.08 6.08 23.08 32.08 8.08 11.08 6.08 13.08 13.83 > 16.83 19.83 8.83 20.83 17.83 > [19] 9.83 20.83 10.83 12.83 15.83 11.83 Please provide a reproducible example. You just showed us the print output for an object, claiming that it is an object of class "data.frame" which is rather unlikely given the print output. > I converted this into time series object as follows > > >tsdata <- ts((df),frequency = 12, start = c(1999, 1)) which produces the right result for me if `df' is a vector or a data.frame: df <- c(11.08, 7.08, 7.08, 6.08, 6.08, 6.08, 23.08, 32.08, 8.08, 11.08, 6.08, 13.08, 13.83, 16.83, 19.83, 8.83, 20.83, 17.83, 9.83, 20.83, 10.83, 12.83, 15.83, 11.83) ts(df, frequency = 12, start = c(1999, 1)) ts(as.data.frame(df), frequency = 12, start = c(1999, 1)) > The resulting time series is as follows: > > Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec > 1999 2 15 15 14 14 14 12 13 16 2 14 5 > 2000 6 8 10 17 11 9 18 11 1 4 7 3 > > I am unable to understand why the values of df and tsdata does not match. So are we because you didn't really tell us enough about df... Best, Z > I looked at ts function and I couldn't find any data transformation. Am > I missing something here? Any pointers would be of great help. > > Thanks in advance. > > Sachin > > > - > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > __ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] converting to time series object : ts - package:stats
We don't have data.csv so its still not ***reproducible*** by anyone else. To be reproducible it means that anyone can copy the code in your post, paste it into R and get the same answer. Suggest you post the output of dput(df) and then post dput <- ...the output you got from dput(df)... Now its reproducible. On 6/26/06, Sachin J <[EMAIL PROTECTED]> wrote: > Hi Achim, > > I did the following: > > >df <- read.csv("C:/data.csv", header=TRUE,sep=",",na.strings="NA", dec=",", > strip.white=TRUE) > > Note: data.csv has 10 (V1...V10) columns. > > >df[1] > V1 > 111.08 > 2 7.08 > 3 7.08 > 4 6.08 > 5 6.08 > 6 6.08 > 723.08 > 832.08 > 9 8.08 > 10 11.08 > 116.08 > 12 13.08 > 13 13.83 > 14 16.83 > 15 19.83 > 168.83 > 17 20.83 > 18 17.83 > 199.83 > 20 20.83 > 21 10.83 > 22 12.83 > 23 15.83 > 24 11.83 > > >tsdata <- ts((df[1]),frequency = 12, start = c(2005, 1)) > > The resulting time series is different from the df. I don't know why? I > think I am doing something silly. > > TIA > > Sachin > > > Achim Zeileis <[EMAIL PROTECTED]> wrote: > On Mon, 26 Jun 2006, Sachin J wrote: > > > Hi, > > > > I am trying to convert a dataset (dataframe) into time series object > > using ts function in stats package. My dataset is as follows: > > > > >df > > [1] 11.08 7.08 7.08 6.08 6.08 6.08 23.08 32.08 8.08 11.08 6.08 13.08 13.83 > > 16.83 19.83 8.83 20.83 17.83 > > [19] 9.83 20.83 10.83 12.83 15.83 11.83 > > Please provide a reproducible example. You just showed us the print output > for an object, claiming that it is an object of class "data.frame" which > is rather unlikely given the print output. > > > I converted this into time series object as follows > > > > >tsdata <- ts((df),frequency = 12, start = c(1999, 1)) > > which produces the right result for me if `df' is a vector or a > data.frame: > > df <- c(11.08, 7.08, 7.08, 6.08, 6.08, 6.08, 23.08, 32.08, 8.08, 11.08, > 6.08, 13.08, 13.83, 16.83, 19.83, 8.83, 20.83, 17.83, 9.83, 20.83, > 10.83, 12.83, 15.83, 11.83) > ts(df, frequency = 12, start = c(1999, 1)) > ts(as.data.frame(df), frequency = 12, start = c(1999, 1)) > > > The resulting time series is as follows: > > > > Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec > > 1999 2 15 15 14 14 14 12 13 16 2 14 5 > > 2000 6 8 10 17 11 9 18 11 1 4 7 3 > > > > I am unable to understand why the values of df and tsdata does not match. > > So are we because you didn't really tell us enough about df... > > Best, > Z > > > I looked at ts function and I couldn't find any data transformation. Am > > I missing something here? Any pointers would be of great help. > > > > Thanks in advance. > > > > Sachin > > > > > > - > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html > > > > > __ > > > >[[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] converting to time series object : ts - package:stats
You are right. The df is as follows: >df[1] V1 111.08 2 7.08 3 7.08 4 6.08 5 6.08 6 6.08 723.08 832.08 9 8.08 10 11.08 116.08 12 13.08 13 13.83 14 16.83 15 19.83 168.83 17 20.83 18 17.83 199.83 20 20.83 21 10.83 22 12.83 23 15.83 24 11.83 But when I provide df[,1] it prints as earlier in factor form. How do I take are of this (factor) issue. TIA Sachin Prof Brian Ripley <[EMAIL PROTECTED]> wrote: On Mon, 26 Jun 2006, Sachin J wrote: > I am trying to convert a dataset (dataframe) into time series object > using ts function in stats package. My dataset is as follows: > > >df > [1] 11.08 7.08 7.08 6.08 6.08 6.08 23.08 32.08 8.08 11.08 6.08 13.08 13.83 > 16.83 19.83 8.83 20.83 17.83 > [19] 9.83 20.83 10.83 12.83 15.83 11.83 No data frame will print like that, so it seems that your description and printout do not match. > I converted this into time series object as follows > > >tsdata <- ts((df),frequency = 12, start = c(1999, 1)) >From the help page for ts: data: a numeric vector or matrix of the observed time-series values. A data frame will be coerced to a numeric matrix via 'data.matrix'. I suspect you have a single-column data frame with a factor column. Look up what data.matrix does for factors. > The resulting time series is as follows: > > Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec > 1999 2 15 15 14 14 14 12 13 16 2 14 5 > 2000 6 8 10 17 11 9 18 11 1 4 7 3 > > I am unable to understand why the values of df and tsdata does not > match. I looked at ts function and I couldn't find any data > transformation. Am I missing something here? Any pointers would be of > great help. > > Thanks in advance. > > Sachin > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] converting to time series object : ts - package:stats
Sorry I meant issue dput(df) and post df <- ...the output your got from dput(df)... ...rest of your code... Now its reproducible. On 6/26/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > We don't have data.csv so its still not ***reproducible*** by anyone > else. To be reproducible it means that anyone can copy the code > in your post, paste it into R and get the same answer. > > Suggest you post the output of > dput(df) > > and then post > dput <- ...the output you got from dput(df)... > > Now its reproducible. > > On 6/26/06, Sachin J <[EMAIL PROTECTED]> wrote: > > Hi Achim, > > > > I did the following: > > > > >df <- read.csv("C:/data.csv", header=TRUE,sep=",",na.strings="NA", > > dec=",", strip.white=TRUE) > > > > Note: data.csv has 10 (V1...V10) columns. > > > > >df[1] > > V1 > > 111.08 > > 2 7.08 > > 3 7.08 > > 4 6.08 > > 5 6.08 > > 6 6.08 > > 723.08 > > 832.08 > > 9 8.08 > > 10 11.08 > > 116.08 > > 12 13.08 > > 13 13.83 > > 14 16.83 > > 15 19.83 > > 168.83 > > 17 20.83 > > 18 17.83 > > 199.83 > > 20 20.83 > > 21 10.83 > > 22 12.83 > > 23 15.83 > > 24 11.83 > > > > >tsdata <- ts((df[1]),frequency = 12, start = c(2005, 1)) > > > > The resulting time series is different from the df. I don't know why? I > > think I am doing something silly. > > > > TIA > > > > Sachin > > > > > > Achim Zeileis <[EMAIL PROTECTED]> wrote: > > On Mon, 26 Jun 2006, Sachin J wrote: > > > > > Hi, > > > > > > I am trying to convert a dataset (dataframe) into time series object > > > using ts function in stats package. My dataset is as follows: > > > > > > >df > > > [1] 11.08 7.08 7.08 6.08 6.08 6.08 23.08 32.08 8.08 11.08 6.08 13.08 > > > 13.83 16.83 19.83 8.83 20.83 17.83 > > > [19] 9.83 20.83 10.83 12.83 15.83 11.83 > > > > Please provide a reproducible example. You just showed us the print output > > for an object, claiming that it is an object of class "data.frame" which > > is rather unlikely given the print output. > > > > > I converted this into time series object as follows > > > > > > >tsdata <- ts((df),frequency = 12, start = c(1999, 1)) > > > > which produces the right result for me if `df' is a vector or a > > data.frame: > > > > df <- c(11.08, 7.08, 7.08, 6.08, 6.08, 6.08, 23.08, 32.08, 8.08, 11.08, > > 6.08, 13.08, 13.83, 16.83, 19.83, 8.83, 20.83, 17.83, 9.83, 20.83, > > 10.83, 12.83, 15.83, 11.83) > > ts(df, frequency = 12, start = c(1999, 1)) > > ts(as.data.frame(df), frequency = 12, start = c(1999, 1)) > > > > > The resulting time series is as follows: > > > > > > Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec > > > 1999 2 15 15 14 14 14 12 13 16 2 14 5 > > > 2000 6 8 10 17 11 9 18 11 1 4 7 3 > > > > > > I am unable to understand why the values of df and tsdata does not match. > > > > So are we because you didn't really tell us enough about df... > > > > Best, > > Z > > > > > I looked at ts function and I couldn't find any data transformation. Am > > > I missing something here? Any pointers would be of great help. > > > > > > Thanks in advance. > > > > > > Sachin > > > > > > > > > - > > > > > > [[alternative HTML version deleted]] > > > > > > __ > > > R-help@stat.math.ethz.ch mailing list > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide! > > > http://www.R-project.org/posting-guide.html > > > > > > > > > __ > > > > > > > >[[alternative HTML version deleted]] > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html > > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] converting to time series object : ts - package:stats
It seems I have problem in reading the data as dataframe. It is reading it as factors. Here is the df df <- read.csv("C:/Data.csv",header=TRUE,sep=",",na.strings="NA", dec=",", strip.white=TRUE) > dput(df) > df <- structure(list(V1 = structure(c(2, 15, 15, 14, 14, 14, 12, 13, + 16, 2, 14, 5, 6, 8, 10, 17, 11, 9, 18, 11, 1, 4, 7, 3), .Label = c("10.83", + "11.08", "11.83", "12.83", "13.08", "13.83", "15.83", "16.83", + "17.83", "19.83", "20.83", "23.08", "32.08", "6.08", "7.08", + "8.08", "8.83", "9.83"), class = "factor"), V2 = structure(c(8, + 15, 2, 10, 9, 18, 1, 4, 10, 2, 8, 6, 17, 5, 16, 13, 5, 14, 3, + 11, 3, 12, 7, 7), .Label = c("10.73", "11.73", "11.75", "12.73", + "15.75", "19.73", "19.75", "21.73", "25.73", "26.73", "26.75", + "27.75", "32.75", "33.75", "37.73", "42.75", "61.75", "9.73"), class = "factor"), + V3 = structure(c(3, 8, 7, 9, 11, 9, 3, 8, 10, 9, 11, 10, + 2, 1, 12, 12, 6, 5, 4, 6, 2, 5, 5, 1), .Label = c("10.33", + "12.33", "13.08", "13.33", "14.33", "15.33", "21.08", "6.08", + "7.08", "8.08", "9.08", "9.33"), class = "factor")), .Names = c("V1", + "V2", "V3"), class = "data.frame", row.names = c("1", "2", "3", + "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", + "16", "17", "18", "19", "20", "21", "22", "23", "24")) TIA Sachin Gabor Grothendieck <[EMAIL PROTECTED]> wrote: Sorry I meant issue dput(df) and post df <- ...the output your got from dput(df)... ...rest of your code... Now its reproducible. On 6/26/06, Gabor Grothendieck wrote: > We don't have data.csv so its still not ***reproducible*** by anyone > else. To be reproducible it means that anyone can copy the code > in your post, paste it into R and get the same answer. > > Suggest you post the output of > dput(df) > > and then post > dput <- ...the output you got from dput(df)... > > Now its reproducible. > > On 6/26/06, Sachin J wrote: > > Hi Achim, > > > > I did the following: > > > > >df <- read.csv("C:/data.csv", header=TRUE,sep=",",na.strings="NA", > > >dec=",", strip.white=TRUE) > > > > Note: data.csv has 10 (V1...V10) columns. > > > > >df[1] > > V1 > > 1 11.08 > > 2 7.08 > > 3 7.08 > > 4 6.08 > > 5 6.08 > > 6 6.08 > > 7 23.08 > > 8 32.08 > > 9 8.08 > > 10 11.08 > > 11 6.08 > > 12 13.08 > > 13 13.83 > > 14 16.83 > > 15 19.83 > > 16 8.83 > > 17 20.83 > > 18 17.83 > > 19 9.83 > > 20 20.83 > > 21 10.83 > > 22 12.83 > > 23 15.83 > > 24 11.83 > > > > >tsdata <- ts((df[1]),frequency = 12, start = c(2005, 1)) > > > > The resulting time series is different from the df. I don't know why? I > > think I am doing something silly. > > > > TIA > > > > Sachin > > > > > > Achim Zeileis wrote: > > On Mon, 26 Jun 2006, Sachin J wrote: > > > > > Hi, > > > > > > I am trying to convert a dataset (dataframe) into time series object > > > using ts function in stats package. My dataset is as follows: > > > > > > >df > > > [1] 11.08 7.08 7.08 6.08 6.08 6.08 23.08 32.08 8.08 11.08 6.08 13.08 > > > 13.83 16.83 19.83 8.83 20.83 17.83 > > > [19] 9.83 20.83 10.83 12.83 15.83 11.83 > > > > Please provide a reproducible example. You just showed us the print output > > for an object, claiming that it is an object of class "data.frame" which > > is rather unlikely given the print output. > > > > > I converted this into time series object as follows > > > > > > >tsdata <- ts((df),frequency = 12, start = c(1999, 1)) > > > > which produces the right result for me if `df' is a vector or a > > data.frame: > > > > df <- c(11.08, 7.08, 7.08, 6.08, 6.08, 6.08, 23.08, 32.08, 8.08, 11.08, > > 6.08, 13.08, 13.83, 16.83, 19.83, 8.83, 20.83, 17.83, 9.83, 20.83, > > 10.83, 12.83, 15.83, 11.83) > > ts(df, frequency = 12, start = c(1999, 1)) > > ts(as.data.frame(df), frequency = 12, start = c(1999, 1)) > > > > > The resulting time series is as follows: > > > > > > Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec > > > 1999 2 15 15 14 14 14 12 13 16 2 14 5 > > > 2000 6 8 10 17 11 9 18 11 1 4 7 3 > > > > > > I am unable to understand why the values of df and tsdata does not match. > > > > So are we because you didn't really tell us enough about df... > > > > Best, > > Z > > > > > I looked at ts function and I couldn't find any data transformation. Am > > > I missing something here? Any pointers would be of great help. > > > > > > Thanks in advance. > > > > > > Sachin > > > > > > > > > - > > > > > > [[alternative HTML version deleted]] > > > > > > __ > > > R-help@stat.math.ethz.ch mailing list > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide! > > > http://www.R-project.org/posting-guide.html > > > > > > > > > __ > > > > > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLE
Re: [R] Puzzled with contour()
On 6/25/2006 9:33 AM, Ajay Narottam Shah wrote: > Folks, > > The contour() function wants x and y to be in increasing order. I have > a situation where I have a grid in x and y, and associated z values, > which looks like this: contour() wants vectors of x and y values, and a matrix of z values, where the x values correspond to the rows of z, and the y values to the columns. You have a collection of points which need to be turned into such a grid. There's an interp function in the akima package that can do this in general. In your case, it's probably sufficient to do something like this: zmat <- matrix(NA, 3, 19) zmat[cbind(20*x + 1, y/10 - 1)] <- z x <- (0:2)/20 y <- (2:20)*10 contour(x,y,zmat) Duncan Murdoch > > x y z > [1,] 0.00 20 1.000 > [2,] 0.00 30 1.000 > [3,] 0.00 40 1.000 > [4,] 0.00 50 1.000 > [5,] 0.00 60 1.000 > [6,] 0.00 70 1.000 > [7,] 0.00 80 0.000 > [8,] 0.00 90 0.000 > [9,] 0.00 100 0.000 > [10,] 0.00 110 0.000 > [11,] 0.00 120 0.000 > [12,] 0.00 130 0.000 > [13,] 0.00 140 0.000 > [14,] 0.00 150 0.000 > [15,] 0.00 160 0.000 > [16,] 0.00 170 0.000 > [17,] 0.00 180 0.000 > [18,] 0.00 190 0.000 > [19,] 0.00 200 0.000 > [20,] 0.05 20 1.000 > [21,] 0.05 30 1.000 > [22,] 0.05 40 1.000 > [23,] 0.05 50 1.000 > [24,] 0.05 60 0.998 > [25,] 0.05 70 0.124 > [26,] 0.05 80 0.000 > [27,] 0.05 90 0.000 > [28,] 0.05 100 0.000 > [29,] 0.05 110 0.000 > [30,] 0.05 120 0.000 > [31,] 0.05 130 0.000 > [32,] 0.05 140 0.000 > [33,] 0.05 150 0.000 > [34,] 0.05 160 0.000 > [35,] 0.05 170 0.000 > [36,] 0.05 180 0.000 > [37,] 0.05 190 0.000 > [38,] 0.05 200 0.000 > [39,] 0.10 20 1.000 > [40,] 0.10 30 1.000 > > This looks like a nice case where both x and y are in increasing > order. But contour() gets unhappy saying that he wants x and y in > increasing order. > > Gnuplot generates pretty 3d pictures from such data, where you are > standing above a surface and looking down at it. How does one do that > in R? > > Any help will be most appreciated. A dput() of my data object is : > > structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 0, 0, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, > 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.1, 0.1, > 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, > 0.1, 0.1, 0.1, 0.1, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, > 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, > 0.15, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, > 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.25, 0.25, 0.25, 0.25, > 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, > 0.25, 0.25, 0.25, 0.25, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, > 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.35, > 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, > 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.4, 0.4, 0.4, 0.4, > 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, > 0.4, 0.4, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, > 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.5, > 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, > 0.5, 0.5, 0.5, 0.5, 0.5, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, > 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, > 0.55, 0.55, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, > 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.65, 0.65, 0.65, > 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, > 0.65, 0.65, 0.65, 0.65, 0.65, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, > 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.75, > 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, > 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.8, 0.8, 0.8, 0.8, > 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, > 0.8, 0.8, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, > 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.9, > 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, > 0.9, 0.9, 0.9, 0.9, 0.9, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, > 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, > 0.95, 0.95, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, 1, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, > 150, 160, 170, 180, 190, 200, 20, 30, 40, 50, 60, 70, 80, 90, > 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 20, 30, > 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, > 180, 190, 200, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, > 130, 140, 150, 160, 170, 180, 190, 200, 20, 30, 40, 50, 60, 70, > 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, > 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130,
Re: [R] converting to time series object : ts - package:stats
df[] <- sapply(format(df), as.numeric) will convert it to numeric but I think the real problem is the read.csv statement. Do commas represent separators or decimals since you have specified comma for both? Assuming it looks like: A,B,C 1,2,3 4,5,6 just do: DF <- read.csv("Data.csv") str(DF) On 6/26/06, Sachin J <[EMAIL PROTECTED]> wrote: > > > It seems I have problem in reading the data as dataframe. It is reading it > as factors. Here is the df > > df <- > read.csv("C:/Data.csv",header=TRUE,sep=",",na.strings="NA", > dec=",", strip.white=TRUE) > > > dput(df) > > > df <- structure(list(V1 = structure(c(2, 15, 15, 14, 14, 14, 12, 13, > + 16, 2, 14, 5, 6, 8, 10, 17, 11, 9, 18, 11, 1, 4, 7, 3), .Label = > c("10.83", > + "11.08", "11.83", "12.83", "13.08", "13.83", "15.83", "16.83", > + "17.83", "19.83", "20.83", "23.08", "32.08", "6.08", "7.08", > + "8.08", "8.83", "9.83"), class = "factor"), V2 = structure(c(8, > + 15, 2, 10, 9, 18, 1, 4, 10, 2, 8, 6, 17, 5, 16, 13, 5, 14, 3, > + 11, 3, 12, 7, 7), .Label = c("10.73", "11.73", "11.75", "12.73", > + "15.75", "19.73", "19.75", "21.73", "25.73", "26.73", "26.75", > + "27.75", "32.75", "33.75", "37.73", "42.75", "61.75", "9.73"), class = > "factor"), > + V3 = structure(c(3, 8, 7, 9, 11, 9, 3, 8, 10, 9, 11, 10, > + 2, 1, 12, 12, 6, 5, 4, 6, 2, 5, 5, 1), .Label = c("10.33", > + "12.33", "13.08", "13.33", "14.33", "15.33", "21.08", "6.08", > + "7.08", "8.08", "9.08", "9.33"), class = "factor")), .Names = c("V1", > + "V2", "V3"), class = "data.frame", row.names = c("1", "2", "3", > + "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", > + "16", "17", "18", "19", "20", "21", "22", "23", "24")) > > TIA > > Sachin > > > > > Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > > Sorry I meant issue dput(df) and > post > > df <- ...the output your got from dput(df)... > ...rest of your code... > > Now its reproducible. > > > On 6/26/06, Gabor Grothendieck wrote: > > We don't have data.csv so its still not ***reproducible*** by anyone > > else. To be reproducible it means that anyone can copy the code > > in your post, paste it into R and get the same answer. > > > > Suggest you post the output of > > dput(df) > > > > and then post > > dput <- ...the output you got from dput(df)... > > > > Now its reproducible. > > > > On 6/26/06, Sachin J wrote: > > > Hi Achim, > > > > > > I did the following: > > > > > > >df <- read.csv("C:/data.csv", header=TRUE,sep=",",na.strings="NA", > dec=",", strip.white=TRUE) > > > > > > Note: data.csv has 10 (V1...V10) columns. > > > > > > >df[1] > > > V1 > > > 1 11.08 > > > 2 7.08 > > > 3 7.08 > > > 4 6.08 > > > 5 6.08 > > > 6 6.08 > > > 7 23.08 > > > 8 32.08 > > > 9 8.08 > > > 10 11.08 > > > 11 6.08 > > > 12 13.08 > > > 13 13.83 > > > 14 16.83 > > > 15 19.83 > > > 16 8.83 > > > 17 20.83 > > > 18 17.83 > > > 19 9.83 > > > 20 20.83 > > > 21 10.83 > > > 22 12.83 > > > 23 15.83 > > > 24 11.83 > > > > > > >tsdata <- ts((df[1]),frequency = 12, start = c(2005, 1)) > > > > > > The resulting time series is different from the df. I don't know why? I > think I am doing something silly. > > > > > > TIA > > > > > > Sachin > > > > > > > > > Achim Zeileis wrote: > > > On Mon, 26 Jun 2006, Sachin J wrote: > > > > > > > Hi, > > > > > > > > I am trying to convert a dataset (dataframe) into time series object > > > > using ts function in stats package. My dataset is as follows: > > > > > > > > >df > > > > [1] 11.08 7.08 7.08 6.08 6.08 6.08 23.08 32.08 8.08 11.08 6.08 13.08 > 13.83 16.83 19.83 8.83 20.83 17.83 > > > > [19] 9.83 20.83 10.83 12.83 15.83 11.83 > > > > > > Please provide a reproducible example. You just showed us the print > output > > > for an object, claiming that it is an object of class "data.frame" which > > > is rather unlikely given the print output. > > > > > > > I converted this into time series object as follows > > > > > > > > >tsdata <- ts((df),frequency = 12, start = c(1999, 1)) > > > > > > which produces the right result for me if `df' is a vector or a > > > data.frame: > > > > > > df <- c(11.08, 7.08, 7.08, 6.08, 6.08, 6.08, 23.08, 32.08, 8.08, 11.08, > > > 6.08, 13.08, 13.83, 16.83, 19.83, 8.83, 20.83, 17.83, 9.83, 20.83, > > > 10.83, 12.83, 15.83, 11.83) > > > ts(df, frequency = 12, start = c(1999, 1)) > > > ts(as.data.frame(df), frequency = 12, start = c(1999, 1)) > > > > > > > The resulting time series is as follows: > > > > > > > > Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec > > > > 1999 2 15 15 14 14 14 12 13 16 2 14 5 > > > > 2000 6 8 10 17 11 9 18 11 1 4 7 3 > > > > > > > > I am unable to understand why the values of df and tsdata does not > match. > > > > > > So are we because you didn't really tell us enough about df... > > > > > > Best, > > > Z > > > > > > > I looked at ts function and I couldn't find any data transformation. > Am > > > > I missing something here? Any pointers would be of great help. > > > > > > > > Thanks in advance. > > > > > > > > Sachin > > > > > > > > > > > > --
Re: [R] Puzzled with contour()
I think it would be helpful if this were added to the contour help file. On 6/26/06, Duncan Murdoch <[EMAIL PROTECTED]> wrote: > On 6/25/2006 9:33 AM, Ajay Narottam Shah wrote: > > Folks, > > > > The contour() function wants x and y to be in increasing order. I have > > a situation where I have a grid in x and y, and associated z values, > > which looks like this: > > contour() wants vectors of x and y values, and a matrix of z values, > where the x values correspond to the rows of z, and the y values to the > columns. You have a collection of points which need to be turned into > such a grid. > > There's an interp function in the akima package that can do this in > general. In your case, it's probably sufficient to do something like this: > > zmat <- matrix(NA, 3, 19) > zmat[cbind(20*x + 1, y/10 - 1)] <- z > x <- (0:2)/20 > y <- (2:20)*10 > contour(x,y,zmat) > > Duncan Murdoch > > > > > > x y z > > [1,] 0.00 20 1.000 > > [2,] 0.00 30 1.000 > > [3,] 0.00 40 1.000 > > [4,] 0.00 50 1.000 > > [5,] 0.00 60 1.000 > > [6,] 0.00 70 1.000 > > [7,] 0.00 80 0.000 > > [8,] 0.00 90 0.000 > > [9,] 0.00 100 0.000 > > [10,] 0.00 110 0.000 > > [11,] 0.00 120 0.000 > > [12,] 0.00 130 0.000 > > [13,] 0.00 140 0.000 > > [14,] 0.00 150 0.000 > > [15,] 0.00 160 0.000 > > [16,] 0.00 170 0.000 > > [17,] 0.00 180 0.000 > > [18,] 0.00 190 0.000 > > [19,] 0.00 200 0.000 > > [20,] 0.05 20 1.000 > > [21,] 0.05 30 1.000 > > [22,] 0.05 40 1.000 > > [23,] 0.05 50 1.000 > > [24,] 0.05 60 0.998 > > [25,] 0.05 70 0.124 > > [26,] 0.05 80 0.000 > > [27,] 0.05 90 0.000 > > [28,] 0.05 100 0.000 > > [29,] 0.05 110 0.000 > > [30,] 0.05 120 0.000 > > [31,] 0.05 130 0.000 > > [32,] 0.05 140 0.000 > > [33,] 0.05 150 0.000 > > [34,] 0.05 160 0.000 > > [35,] 0.05 170 0.000 > > [36,] 0.05 180 0.000 > > [37,] 0.05 190 0.000 > > [38,] 0.05 200 0.000 > > [39,] 0.10 20 1.000 > > [40,] 0.10 30 1.000 > > > > This looks like a nice case where both x and y are in increasing > > order. But contour() gets unhappy saying that he wants x and y in > > increasing order. > > > > Gnuplot generates pretty 3d pictures from such data, where you are > > standing above a surface and looking down at it. How does one do that > > in R? > > > > Any help will be most appreciated. A dput() of my data object is : > > > > structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > > 0, 0, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, > > 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.1, 0.1, > > 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, > > 0.1, 0.1, 0.1, 0.1, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, > > 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, > > 0.15, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, > > 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.25, 0.25, 0.25, 0.25, > > 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, > > 0.25, 0.25, 0.25, 0.25, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, > > 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.35, > > 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, > > 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.4, 0.4, 0.4, 0.4, > > 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, > > 0.4, 0.4, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, > > 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.5, > > 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, > > 0.5, 0.5, 0.5, 0.5, 0.5, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, > > 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, > > 0.55, 0.55, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, > > 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.65, 0.65, 0.65, > > 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, > > 0.65, 0.65, 0.65, 0.65, 0.65, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, > > 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.75, > > 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, > > 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.8, 0.8, 0.8, 0.8, > > 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, > > 0.8, 0.8, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, > > 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.9, > > 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, > > 0.9, 0.9, 0.9, 0.9, 0.9, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, > > 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, > > 0.95, 0.95, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > > 1, 1, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, > > 150, 160, 170, 180, 190, 200, 20, 30, 40, 50, 60, 70, 80, 90, > > 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 20, 30, > > 40, 50, 60, 7
Re: [R] Puzzled with contour()
On 6/26/2006 10:39 AM, Gabor Grothendieck wrote: > I think it would be helpful if this were added to the contour help file. You mean an example of building up the z matrix from points, or just a general discussion of the issue? Duncan Murdoch > > On 6/26/06, Duncan Murdoch <[EMAIL PROTECTED]> wrote: >> On 6/25/2006 9:33 AM, Ajay Narottam Shah wrote: >> > Folks, >> > >> > The contour() function wants x and y to be in increasing order. I have >> > a situation where I have a grid in x and y, and associated z values, >> > which looks like this: >> >> contour() wants vectors of x and y values, and a matrix of z values, >> where the x values correspond to the rows of z, and the y values to the >> columns. You have a collection of points which need to be turned into >> such a grid. >> >> There's an interp function in the akima package that can do this in >> general. In your case, it's probably sufficient to do something like this: >> >> zmat <- matrix(NA, 3, 19) >> zmat[cbind(20*x + 1, y/10 - 1)] <- z >> x <- (0:2)/20 >> y <- (2:20)*10 >> contour(x,y,zmat) >> >> Duncan Murdoch >> >> >> > >> > x y z >> > [1,] 0.00 20 1.000 >> > [2,] 0.00 30 1.000 >> > [3,] 0.00 40 1.000 >> > [4,] 0.00 50 1.000 >> > [5,] 0.00 60 1.000 >> > [6,] 0.00 70 1.000 >> > [7,] 0.00 80 0.000 >> > [8,] 0.00 90 0.000 >> > [9,] 0.00 100 0.000 >> > [10,] 0.00 110 0.000 >> > [11,] 0.00 120 0.000 >> > [12,] 0.00 130 0.000 >> > [13,] 0.00 140 0.000 >> > [14,] 0.00 150 0.000 >> > [15,] 0.00 160 0.000 >> > [16,] 0.00 170 0.000 >> > [17,] 0.00 180 0.000 >> > [18,] 0.00 190 0.000 >> > [19,] 0.00 200 0.000 >> > [20,] 0.05 20 1.000 >> > [21,] 0.05 30 1.000 >> > [22,] 0.05 40 1.000 >> > [23,] 0.05 50 1.000 >> > [24,] 0.05 60 0.998 >> > [25,] 0.05 70 0.124 >> > [26,] 0.05 80 0.000 >> > [27,] 0.05 90 0.000 >> > [28,] 0.05 100 0.000 >> > [29,] 0.05 110 0.000 >> > [30,] 0.05 120 0.000 >> > [31,] 0.05 130 0.000 >> > [32,] 0.05 140 0.000 >> > [33,] 0.05 150 0.000 >> > [34,] 0.05 160 0.000 >> > [35,] 0.05 170 0.000 >> > [36,] 0.05 180 0.000 >> > [37,] 0.05 190 0.000 >> > [38,] 0.05 200 0.000 >> > [39,] 0.10 20 1.000 >> > [40,] 0.10 30 1.000 >> > >> > This looks like a nice case where both x and y are in increasing >> > order. But contour() gets unhappy saying that he wants x and y in >> > increasing order. >> > >> > Gnuplot generates pretty 3d pictures from such data, where you are >> > standing above a surface and looking down at it. How does one do that >> > in R? >> > >> > Any help will be most appreciated. A dput() of my data object is : >> > >> > structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, >> > 0, 0, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, >> > 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.1, 0.1, >> > 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, >> > 0.1, 0.1, 0.1, 0.1, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, >> > 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, >> > 0.15, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, >> > 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.25, 0.25, 0.25, 0.25, >> > 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, >> > 0.25, 0.25, 0.25, 0.25, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, >> > 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.35, >> > 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, >> > 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.4, 0.4, 0.4, 0.4, >> > 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, >> > 0.4, 0.4, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, >> > 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.5, >> > 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, >> > 0.5, 0.5, 0.5, 0.5, 0.5, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, >> > 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, >> > 0.55, 0.55, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, >> > 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.65, 0.65, 0.65, >> > 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, >> > 0.65, 0.65, 0.65, 0.65, 0.65, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, >> > 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.75, >> > 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, >> > 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.8, 0.8, 0.8, 0.8, >> > 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, >> > 0.8, 0.8, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, >> > 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.9, >> > 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, >> > 0.9, 0.9, 0.9, 0.9, 0.9, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, >> > 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95
Re: [R] converting to time series object : ts - package:stats
Hi Gabor, You are correct. The real problem is with read.csv. I am not sure why? My data looks V1,V2,V3 11.08,21.73,13.08 7.08,37.73,6.08 7.08,11.73,21.08 I never had this problem earlier. Anyway I did >df <- read.csv("Data.csv") >tsdata <- ts((df),frequency = 12, start = c(1999, 1)) it works fine. But still puzzled with read.csv behavior. Any thoughts? Thanx Gabor, Achim and Brian for your help. Sachin Gabor Grothendieck <[EMAIL PROTECTED]> wrote: df[] <- sapply(format(df), as.numeric) will convert it to numeric but I think the real problem is the read.csv statement. Do commas represent separators or decimals since you have specified comma for both? Assuming it looks like: A,B,C 1,2,3 4,5,6 just do: DF <- read.csv("Data.csv") str(DF) On 6/26/06, Sachin J wrote: > > > It seems I have problem in reading the data as dataframe. It is reading it > as factors. Here is the df > > df <- > read.csv("C:/Data.csv",header=TRUE,sep=",",na.strings="NA", > dec=",", strip.white=TRUE) > > > dput(df) > > > df <- structure(list(V1 = structure(c(2, 15, 15, 14, 14, 14, 12, 13, > + 16, 2, 14, 5, 6, 8, 10, 17, 11, 9, 18, 11, 1, 4, 7, 3), .Label = > c("10.83", > + "11.08", "11.83", "12.83", "13.08", "13.83", "15.83", "16.83", > + "17.83", "19.83", "20.83", "23.08", "32.08", "6.08", "7.08", > + "8.08", "8.83", "9.83"), class = "factor"), V2 = structure(c(8, > + 15, 2, 10, 9, 18, 1, 4, 10, 2, 8, 6, 17, 5, 16, 13, 5, 14, 3, > + 11, 3, 12, 7, 7), .Label = c("10.73", "11.73", "11.75", "12.73", > + "15.75", "19.73", "19.75", "21.73", "25.73", "26.73", "26.75", > + "27.75", "32.75", "33.75", "37.73", "42.75", "61.75", "9.73"), class = > "factor"), > + V3 = structure(c(3, 8, 7, 9, 11, 9, 3, 8, 10, 9, 11, 10, > + 2, 1, 12, 12, 6, 5, 4, 6, 2, 5, 5, 1), .Label = c("10.33", > + "12.33", "13.08", "13.33", "14.33", "15.33", "21.08", "6.08", > + "7.08", "8.08", "9.08", "9.33"), class = "factor")), .Names = c("V1", > + "V2", "V3"), class = "data.frame", row.names = c("1", "2", "3", > + "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", > + "16", "17", "18", "19", "20", "21", "22", "23", "24")) > > TIA > > Sachin > > > > > Gabor Grothendieck wrote: > > Sorry I meant issue dput(df) and > post > > df <- ...the output your got from dput(df)... > ...rest of your code... > > Now its reproducible. > > > On 6/26/06, Gabor Grothendieck wrote: > > We don't have data.csv so its still not ***reproducible*** by anyone > > else. To be reproducible it means that anyone can copy the code > > in your post, paste it into R and get the same answer. > > > > Suggest you post the output of > > dput(df) > > > > and then post > > dput <- ...the output you got from dput(df)... > > > > Now its reproducible. > > > > On 6/26/06, Sachin J wrote: > > > Hi Achim, > > > > > > I did the following: > > > > > > >df <- read.csv("C:/data.csv", header=TRUE,sep=",",na.strings="NA", > dec=",", strip.white=TRUE) > > > > > > Note: data.csv has 10 (V1...V10) columns. > > > > > > >df[1] > > > V1 > > > 1 11.08 > > > 2 7.08 > > > 3 7.08 > > > 4 6.08 > > > 5 6.08 > > > 6 6.08 > > > 7 23.08 > > > 8 32.08 > > > 9 8.08 > > > 10 11.08 > > > 11 6.08 > > > 12 13.08 > > > 13 13.83 > > > 14 16.83 > > > 15 19.83 > > > 16 8.83 > > > 17 20.83 > > > 18 17.83 > > > 19 9.83 > > > 20 20.83 > > > 21 10.83 > > > 22 12.83 > > > 23 15.83 > > > 24 11.83 > > > > > > >tsdata <- ts((df[1]),frequency = 12, start = c(2005, 1)) > > > > > > The resulting time series is different from the df. I don't know why? I > think I am doing something silly. > > > > > > TIA > > > > > > Sachin > > > > > > > > > Achim Zeileis wrote: > > > On Mon, 26 Jun 2006, Sachin J wrote: > > > > > > > Hi, > > > > > > > > I am trying to convert a dataset (dataframe) into time series object > > > > using ts function in stats package. My dataset is as follows: > > > > > > > > >df > > > > [1] 11.08 7.08 7.08 6.08 6.08 6.08 23.08 32.08 8.08 11.08 6.08 13.08 > 13.83 16.83 19.83 8.83 20.83 17.83 > > > > [19] 9.83 20.83 10.83 12.83 15.83 11.83 > > > > > > Please provide a reproducible example. You just showed us the print > output > > > for an object, claiming that it is an object of class "data.frame" which > > > is rather unlikely given the print output. > > > > > > > I converted this into time series object as follows > > > > > > > > >tsdata <- ts((df),frequency = 12, start = c(1999, 1)) > > > > > > which produces the right result for me if `df' is a vector or a > > > data.frame: > > > > > > df <- c(11.08, 7.08, 7.08, 6.08, 6.08, 6.08, 23.08, 32.08, 8.08, 11.08, > > > 6.08, 13.08, 13.83, 16.83, 19.83, 8.83, 20.83, 17.83, 9.83, 20.83, > > > 10.83, 12.83, 15.83, 11.83) > > > ts(df, frequency = 12, start = c(1999, 1)) > > > ts(as.data.frame(df), frequency = 12, start = c(1999, 1)) > > > > > > > The resulting time series is as follows: > > > > > > > > Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec > > > > 1999 2 15 15 14 14 14 12 13 16 2 14 5 > > > > 2000 6 8 10 17 11 9 18 11 1 4 7 3
Re: [R] converting to time series object : ts - package:stats
I think the problem is that you specified the decimal character to be a comma so when it saw the dot it figured its not a number. On 6/26/06, Sachin J <[EMAIL PROTECTED]> wrote: > > Hi Gabor, > > You are correct. The real problem is with read.csv. I am not sure why? My > data looks > > V1,V2,V3 > 11.08,21.73,13.08 > 7.08,37.73,6.08 > 7.08,11.73,21.08 > > I never had this problem earlier. Anyway I did > > >df <- read.csv("Data.csv") > >tsdata <- ts((df),frequency = 12, start = c(1999, 1)) > > it works fine. But still puzzled with read.csv behavior. Any thoughts? > > Thanx Gabor, Achim and Brian for your help. > > Sachin > > Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > > df[] <- sapply(format(df), as.numeric) > > will convert it to numeric but I think the real problem is the read.csv > statement. Do commas represent separators or decimals since > you have specified comma for both? Assuming it looks like: > > A,B,C > 1,2,3 > 4,5,6 > > just do: > > DF <- read.csv("Data.csv") > str(DF) > > > > > On 6/26/06, Sachin J wrote: > > > > > > It seems I have problem in reading the data as dataframe. It is reading it > > as factors. Here is the df > > > > df <- > > > read.csv("C:/Data.csv",header=TRUE,sep=",",na.strings="NA", > > dec=",", strip.white=TRUE) > > > > > dput(df) > > > > > df <- structure(list(V1 = structure(c(2, 15, 15, 14, 14, 14, 12, 13, > > + 16, 2, 14, 5, 6, 8, 10, 17, 11, 9, 18, 11, 1, 4, 7, 3), .Label = > > c("10.83", > > + "11.08", "11.83", "12.83", "13.08", "13.83", "15.83", "16.83", > > + "17.83", "19.83", "20.83", "23.08", "32.08", "6.08", "7.08", > > + "8.08", "8.83", "9.83"), class = "factor"), V2 = structure(c(8, > > + 15, 2, 10, 9, 18, 1, 4, 10, 2, 8, 6, 17, 5, 16, 13, 5, 14, 3, > > + 11, 3, 12, 7, 7), .Label = c("10.73", "11.73", "11.75", "12.73", > > + "15.75", "19.73", "19.75", "21.73", "25.73", "26.73", "26.75", > > + "27.75", "32.75", "33.75", "37.73", "42.75", "61.75", "9.73"), class = > > "factor"), > > + V3 = structure(c(3, 8, 7, 9, 11, 9, 3, 8, 10, 9, 11, 10, > > + 2, 1, 12, 12, 6, 5, 4, 6, 2, 5, 5, 1), .Label = c("10.33", > > + "12.33", "13.08", "13.33", "14.33", "15.33", "21.08", "6.08", > > + "7.08", "8.08", "9.08", "9.33"), class = "factor")), .Names = c("V1", > > + "V2", "V3"), class = "data.frame", row.names = c("1", "2", "3", > > + "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", > > + "16", "17", "18", "19", "20", "21", "22", "23", "24")) > > > > TIA > > > > Sachin > > > > > > > > > > Gabor Grothendieck wrote: > > > > Sorry I meant issue dput(df) and > > post > > > > df <- ...the output your got from dput(df)... > > ...rest of your code... > > > > Now its reproducible. > > > > > > On 6/26/06, Gabor Grothendieck wrote: > > > We don't have data.csv so its still not ***reproducible*** by anyone > > > else. To be reproducible it means that anyone can copy the code > > > in your post, paste it into R and get the same answer. > > > > > > Suggest you post the output of > > > dput(df) > > > > > > and then post > > > dput <- ...the output you got from dput(df)... > > > > > > Now its reproducible. > > > > > > On 6/26/06, Sachin J wrote: > > > > Hi Achim, > > > > > > > > I did the following: > > > > > > > > >df <- read.csv("C:/data.csv", header=TRUE,sep=",",na.strings="NA", > > dec=",", strip.white=TRUE) > > > > > > > > Note: data.csv has 10 (V1...V10) columns. > > > > > > > > >df[1] > > > > V1 > > > > 1 11.08 > > > > 2 7.08 > > > > 3 7.08 > > > > 4 6.08 > > > > 5 6.08 > > > > 6 6.08 > > > > 7 23.08 > > > > 8 32.08 > > > > 9 8.08 > > > > 10 11.08 > > > > 11 6.08 > > > > 12 13.08 > > > > 13 13.83 > > > > 14 16.83 > > > > 15 19.83 > > > > 16 8.83 > > > > 17 20.83 > > > > 18 17.83 > > > > 19 9.83 > > > > 20 20.83 > > > > 21 10.83 > > > > 22 12.83 > > > > 23 15.83 > > > > 24 11.83 > > > > > > > > >tsdata <- ts((df[1]),frequency = 12, start = c(2005, 1)) > > > > > > > > The resulting time series is different from the df. I don't know why? > I > > think I am doing something silly. > > > > > > > > TIA > > > > > > > > Sachin > > > > > > > > > > > > Achim Zeileis wrote: > > > > On Mon, 26 Jun 2006, Sachin J wrote: > > > > > > > > > Hi, > > > > > > > > > > I am trying to convert a dataset (dataframe) into time series object > > > > > using ts function in stats package. My dataset is as follows: > > > > > > > > > > >df > > > > > [1] 11.08 7.08 7.08 6.08 6.08 6.08 23.08 32.08 8.08 11.08 6.08 13.08 > > 13.83 16.83 19.83 8.83 20.83 17.83 > > > > > [19] 9.83 20.83 10.83 12.83 15.83 11.83 > > > > > > > > Please provide a reproducible example. You just showed us the print > > output > > > > for an object, claiming that it is an object of class "data.frame" > which > > > > is rather unlikely given the print output. > > > > > > > > > I converted this into time series object as follows > > > > > > > > > > >tsdata <- ts((df),frequency = 12, start = c(1999, 1)) > > > > > > > > which produces the right result for me if `df' is a vector or a > > > > data.frame: > > > > > > > > df <- c(11.
Re: [R] Puzzled with contour()
I think its often the case that one has 3 tuples and does not know how to use contour with that; so, it would be nice if the contour help page gave advice and an example and a pointer to the relevant functions if it cannot be done by contour. On 6/26/06, Duncan Murdoch <[EMAIL PROTECTED]> wrote: > On 6/26/2006 10:39 AM, Gabor Grothendieck wrote: > > I think it would be helpful if this were added to the contour help file. > > You mean an example of building up the z matrix from points, or just a > general discussion of the issue? > > Duncan Murdoch > > > > On 6/26/06, Duncan Murdoch <[EMAIL PROTECTED]> wrote: > >> On 6/25/2006 9:33 AM, Ajay Narottam Shah wrote: > >> > Folks, > >> > > >> > The contour() function wants x and y to be in increasing order. I have > >> > a situation where I have a grid in x and y, and associated z values, > >> > which looks like this: > >> > >> contour() wants vectors of x and y values, and a matrix of z values, > >> where the x values correspond to the rows of z, and the y values to the > >> columns. You have a collection of points which need to be turned into > >> such a grid. > >> > >> There's an interp function in the akima package that can do this in > >> general. In your case, it's probably sufficient to do something like this: > >> > >> zmat <- matrix(NA, 3, 19) > >> zmat[cbind(20*x + 1, y/10 - 1)] <- z > >> x <- (0:2)/20 > >> y <- (2:20)*10 > >> contour(x,y,zmat) > >> > >> Duncan Murdoch > >> > >> > >> > > >> > x y z > >> > [1,] 0.00 20 1.000 > >> > [2,] 0.00 30 1.000 > >> > [3,] 0.00 40 1.000 > >> > [4,] 0.00 50 1.000 > >> > [5,] 0.00 60 1.000 > >> > [6,] 0.00 70 1.000 > >> > [7,] 0.00 80 0.000 > >> > [8,] 0.00 90 0.000 > >> > [9,] 0.00 100 0.000 > >> > [10,] 0.00 110 0.000 > >> > [11,] 0.00 120 0.000 > >> > [12,] 0.00 130 0.000 > >> > [13,] 0.00 140 0.000 > >> > [14,] 0.00 150 0.000 > >> > [15,] 0.00 160 0.000 > >> > [16,] 0.00 170 0.000 > >> > [17,] 0.00 180 0.000 > >> > [18,] 0.00 190 0.000 > >> > [19,] 0.00 200 0.000 > >> > [20,] 0.05 20 1.000 > >> > [21,] 0.05 30 1.000 > >> > [22,] 0.05 40 1.000 > >> > [23,] 0.05 50 1.000 > >> > [24,] 0.05 60 0.998 > >> > [25,] 0.05 70 0.124 > >> > [26,] 0.05 80 0.000 > >> > [27,] 0.05 90 0.000 > >> > [28,] 0.05 100 0.000 > >> > [29,] 0.05 110 0.000 > >> > [30,] 0.05 120 0.000 > >> > [31,] 0.05 130 0.000 > >> > [32,] 0.05 140 0.000 > >> > [33,] 0.05 150 0.000 > >> > [34,] 0.05 160 0.000 > >> > [35,] 0.05 170 0.000 > >> > [36,] 0.05 180 0.000 > >> > [37,] 0.05 190 0.000 > >> > [38,] 0.05 200 0.000 > >> > [39,] 0.10 20 1.000 > >> > [40,] 0.10 30 1.000 > >> > > >> > This looks like a nice case where both x and y are in increasing > >> > order. But contour() gets unhappy saying that he wants x and y in > >> > increasing order. > >> > > >> > Gnuplot generates pretty 3d pictures from such data, where you are > >> > standing above a surface and looking down at it. How does one do that > >> > in R? > >> > > >> > Any help will be most appreciated. A dput() of my data object is : > >> > > >> > structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > >> > 0, 0, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, > >> > 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.1, 0.1, > >> > 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, > >> > 0.1, 0.1, 0.1, 0.1, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, > >> > 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, > >> > 0.15, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, > >> > 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.25, 0.25, 0.25, 0.25, > >> > 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, > >> > 0.25, 0.25, 0.25, 0.25, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, > >> > 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.35, > >> > 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, > >> > 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.4, 0.4, 0.4, 0.4, > >> > 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, > >> > 0.4, 0.4, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, > >> > 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.5, > >> > 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, > >> > 0.5, 0.5, 0.5, 0.5, 0.5, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, > >> > 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, 0.55, > >> > 0.55, 0.55, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, > >> > 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.65, 0.65, 0.65, > >> > 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, 0.65, > >> > 0.65, 0.65, 0.65, 0.65, 0.65, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, > >> > 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.75, > >> > 0.75, 0.75, 0.75, 0.75, 0.75, 0
Re: [R] converting to time series object : ts - package:stats
Sachin J <[EMAIL PROTECTED]> writes: > Hi Gabor, > > You are correct. The real problem is with read.csv. I am not sure why? My > data looks > > V1,V2,V3 > 11.08,21.73,13.08 > 7.08,37.73,6.08 > 7.08,11.73,21.08 > > read.csv("C:/Data.csv",header=TRUE,sep=",",na.strings="NA", > > dec=",", strip.white=TRUE) If that's how it looks, then dec="," is wrong. It sets the decimal separator, so expects 11,08 etc. You want dec=".". In general, having sep and dec set to the same value is asking for trouble, and you didn't actually need to depart from the default settings, except for the strip.white bit. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lmer and mixed effects logistic regression
Rick Bilonick wrote: > On Fri, 2006-06-23 at 21:38 -0700, Spencer Graves wrote: >>Permit me to try to repeat what I said earlier a little more clearly: >> When the outcomes are constant for each subject, either all 0's or all >> 1's, the maximum likelihood estimate of the between-subject variance in >> Inf. Any software that returns a different answer is wrong. This is NOT >> a criticism of 'lmer' or SAS NLMIXED: This is a sufficiently rare, >> extreme case that the software does not test for it and doesn't handle >> it well when it occurs. Adding other explanatory variables to the model >> only makes this problem worse, because anything that will produce >> complete separation for each subject will produce this kind of >> instability. >> >> Consider the following: >> >> library(lme4) >> DF <- data.frame(y=c(0,0, 0,1, 1,1), >> Subj=rep(letters[1:3], each=2), >> x=rep(c(-1, 1), 3)) >> fit1 <- lmer(y~1+(1|Subj), data=DF, family=binomial) >> >> # 'lmer' works fine here, because the outcomes from >> # 1 of the 3 subjects is not constant. >> >> > fit.x <- lmer(y~x+(1|Subj), data=DF, family=binomial) >> Warning message: >> IRLS iterations for PQL did not converge >> >>The addition of 'x' to the model now allows complete separation for >> each subject. We see this in the result: >> >> Generalized linear mixed model fit using PQL >> >> Random effects: >> Groups NameVariance Std.Dev. >> Subj (Intercept) 3.5357e+20 1.8803e+10 >> number of obs: 6, groups: Subj, 3 >> >> Estimated scale (compare to 1) 9.9414e-09 >> >> Fixed effects: >> Estimate Std. Errorz value Pr(>|z|) >> (Intercept) -5.4172e-05 1.0856e+10 -4.99e-151 >> x8.6474e+01 2.7397e+07 3.1563e-061 >> >>Note that the subject variance is 3.5e20, the estimate for x is 86 >> wit a standard error of 2.7e7. All three of these numbers are reaching >> for Inf; lmer quit before it got there. >> >>Does this make any sense, or are we still misunderstanding one >> another? >> >>Hope this helps. >>Spencer Graves >> > Yes, thanks, it's clear. I had created a new data set that has each > subject with just one observation and randomly sampled one observation > from each subject with two observations (they are right and left eyes). > I'm not sure why lmer gives small estimated variances for the random > effects when it should be infinite. SG: If lmer gave me small estimated variances for the random effects, I would check very carefully my model, as I would believe I probably have specified something incorrectly. I ran NLMIXED on the original data > set with several explanatory factors and the variance component was in > the thousands. > > I guess the moral is before you do any computations you have to make > sure the procedure makes sense for the data. > > Rick B. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Plylogenetic analysis
Dear coleges, How to use the genotype from microsatelite markers from many different populations to construct a tridimensional phylogenetic tree with R? Any suggestions? Thank you very much! Baron, Erica Dra. Erica Baron Universidade dos Açores - Departamento de Ciências Agrárias Grupo de Biotecnologia - Campus de Angra Terra-Chã 9701-851 Açores - Portugal Tel. +351 295 402 235 Fax. +351 295 402 205 [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lmer and mixed effects logistic regression
> Rick Bilonick wrote: > > I guess the moral is before you do any computations you have to make > > sure the procedure makes sense for the data. > > Is this a candidate for the fortunes package? (an oxymoronic profound, but obvious comment). -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R Reporting - PDF/HTML mature presentation quality package?
The R2HTML package does have a driver for sweave (see help for RweaveHTML). This allows you to write an HTML file and add the R commands you want (use <<>>=, @ combinations to indicate R commands and for inline replacement), then process it with sweave and have a final HTML file (and possibly additional graphic files for the links) with the R output included. Is this what you were looking for? -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jim Lemon Sent: Sunday, June 25, 2006 5:55 PM To: r-help@stat.math.ethz.ch Subject: Re: [R] R Reporting - PDF/HTML mature presentation quality package? I heartily second Phillipe's response. I just started a new job and the first thing required was a neat stats report for a dataset. I thought I would give R2HTML a try and about 5 minutes after downloading it, I was looking at the first draft of the report. I did have to do a bit of hacking on the graphics, but it was easy and I can now present the report first thing in the morning. Had I not been able to do this, I probably would have been told, "You'll have to use SPSS." I was so impressed by R2HTML that I began writing a primitive HTML generator that will scan an R script and do something like R2HTML. I couldn't find anything like this as the svMisc package seems to have disappeared. If anyone knows of something like this or is working on it, I'd appreciate knowing about it. Jim __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How to generate a figure using par( ) with some densityplot( )'s
Hi Dear R users, For a pair plotting, usaully we use par( ) function. Apparently it does not work anywhere. I want to have 3 plots in a single figure, like this: par(mfrow=c(3,1)) densityplot( a) densityplot(b) densityplot(c) But it does not work. How is it possible to have such a figure with densityplot( ) in a single figure? So many thanks for any help. Amir Safari - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Finding a color code.
Hi, Is it possible to find corresponding color code in R for the following RGB (R185, G35 & B80)? Thanks in advance. Best regards, Ezhil __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to generate a figure using par( ) with some densityplot( )'s
Amir Safari wrote: > > Hi Dear R users, > For a pair plotting, usaully we use par( ) function. Apparently it does not > work anywhere. I want to have 3 plots in a single figure, like this: > par(mfrow=c(3,1)) > densityplot( a) > densityplot(b) > densityplot(c) > But it does not work. How is it possible to have such a figure with > densityplot( ) in a single figure? > So many thanks for any help. > Amir Safari > > > Assuming you are talking about densityplot in lattice, then you are missing the point of lattice. You should try: library(lattice) set.seed(1) a <- rnorm(100) b <- rnorm(50) c <- rnorm(75) densityplot(~a + b + c, outer = TRUE, layout = c(3, 1)) Set "outer" to FALSE to overlay the densities (this is the default behavior). You should remove the "layout" argument in that case, though. HTH, --sundar __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] X11 font troubles (Knoppix/Debian unstable)
I'm getting Error in strwidth(...) : X11 font at size 15 could not be loaded kinds of errors when I try to change cex to something *other* than 1 (works OK otherwise). I can't get through to RSiteSearch() right now, but as I recall my search of it only revealed people who had problems because they had failed to install fonts: my Knoppix/tracking Debian unstable distribution claims that the most recent versions of xfonts-100dpi and xfonts-75dpi are both installed. (version 1:1.0.0-2) I'm using the Xorg version of X11. xset -q says: /usr/X11R6/lib/X11/fonts/misc:unscaled,/usr/X11R6/lib/X11/fonts/misc,/usr/X11R6/lib/X11/fonts/75dpi:unscaled, /usr/X11R6/lib/X11/fonts/75dpi,/usr/X11R6/lib/X11/fonts/100dpi:unscaled,/usr/X11R6/lib/X11/fonts/100dpi, /usr/X11R6/lib/X11/fonts/Speedo,/usr/X11R6/lib/X11/fonts/Type1,/usr/share/fonts/ttf/western, /usr/share/fonts/ttf/decoratives,/usr/share/fonts/truetype/ttf-bitstream-vera,/usr/share/fonts/latex-ttf-fonts, /usr/share/fonts/X11/misc/,/usr/share/fonts/X11/Type1/,/usr/share/fonts/X11/100dpi/,/usr/share/fonts/X11/75dpi I haven't noticed any other applications on my system having problems finding fonts, not that that's a very strong test. Any ideas about where to start looking/diagnosing? thanks Ben Bolker __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Finding a color code.
A Ezhil wrote: > Hi, > > Is it possible to find corresponding color code in R > for the following RGB (R185, G35 & B80)? > > Thanks in advance. > > Best regards, > Ezhil > How about: x <- c(185, 35, 80) class(x) <- "hexmode" paste("#", paste(format(x), collapse = ""), sep = "") [1] "#b92350" I found this using help.search("hex") which led to ?format.hexmode. HTH, --sundar __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Finding a color code.
Well, rgb(185, 35, 80, max=255) seems like a good place to start. help.search("rgb") turns up all kinds of color-related functions. Sarah On 6/26/06, A Ezhil <[EMAIL PROTECTED]> wrote: > Hi, > > Is it possible to find corresponding color code in R > for the following RGB (R185, G35 & B80)? > > Thanks in advance. > > Best regards, > Ezhil > -- Sarah Goslee __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Finding a color code.
> ?rgb You will need to divide your values by the maximum or specify it, as in > rgb(185, 35, 80, max=255) on 6/26/2006 12:17 PM A Ezhil said the following: > Is it possible to find corresponding color code in R > for the following RGB (R185, G35 & B80)? > > -- Michael Prager, Ph.D. Southeast Fisheries Science Center NOAA Center for Coastal Fisheries and Habitat Research Beaufort, North Carolina 28516 ** Opinions expressed are personal, not official. No ** official endorsement of any product is made or implied. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Finding a color code.
You can use the following: > rgb(185, 35, 80, max=255) Which gives "#B92350" Or if you want a color name, the closest I found is "maroon" which is red: 176, green: 48, blue: 96 Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of A Ezhil Sent: Monday, June 26, 2006 10:17 AM To: R-help@stat.math.ethz.ch Subject: [R] Finding a color code. Hi, Is it possible to find corresponding color code in R for the following RGB (R185, G35 & B80)? Thanks in advance. Best regards, Ezhil __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to generate a figure using par( ) with some densityplot( )'s
On 6/26/06, Sundar Dorai-Raj <[EMAIL PROTECTED]> wrote: > > > Amir Safari wrote: > > > > Hi Dear R users, > > For a pair plotting, usaully we use par( ) function. Apparently it does > > not work anywhere. I want to have 3 plots in a single figure, like this: > > par(mfrow=c(3,1)) > > densityplot( a) > > densityplot(b) > > densityplot(c) > > But it does not work. How is it possible to have such a figure with > > densityplot( ) in a single figure? > > So many thanks for any help. > > Amir Safari > > > > > > > > Assuming you are talking about densityplot in lattice, then you are > missing the point of lattice. You should try: > > library(lattice) > set.seed(1) > a <- rnorm(100) > b <- rnorm(50) > c <- rnorm(75) > densityplot(~a + b + c, outer = TRUE, layout = c(3, 1)) This only works if a, b and c are of the same length. The following should work though: densityplot(~data | which, data = make.groups(a, b, c)) -Deepayan > Set "outer" to FALSE to overlay the densities (this is the default > behavior). You should remove the "layout" argument in that case, though. > > HTH, > > --sundar -- http://www.stat.wisc.edu/~deepayan/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Finding a color code.
A Ezhil wrote: > Hi, > > Is it possible to find corresponding color code in R > for the following RGB (R185, G35 & B80)? rgb(185, 35, 80, max=255) [1] "#B92350" ?rgb > Thanks in advance. > > Best regards, > Ezhil > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Finding a color code.
Hi Greg, Thank you very much for your response. It works. Thanks also for Michael,Sarah & Sundar. Best regards, Ezhil --- Greg Snow <[EMAIL PROTECTED]> wrote: > You can use the following: > > > rgb(185, 35, 80, max=255) > > Which gives "#B92350" > > Or if you want a color name, the closest I found is > "maroon" which is > red: 176, green: 48, blue: 96 > > Hope this helps, > > > -- > Gregory (Greg) L. Snow Ph.D. > Statistical Data Center > Intermountain Healthcare > [EMAIL PROTECTED] > (801) 408-8111 > > > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf > Of A Ezhil > Sent: Monday, June 26, 2006 10:17 AM > To: R-help@stat.math.ethz.ch > Subject: [R] Finding a color code. > > Hi, > > Is it possible to find corresponding color code in R > for the following > RGB (R185, G35 & B80)? > > Thanks in advance. > > Best regards, > Ezhil > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Package struction question (second try)
Kuhn, Max wrote: > Jay, > > You should use "RCMD install --build pkgName" to create the zip file on > Windows. The zip files you see on CRAN are Windows binaries. You could > also used "RCMD build pkgName", but I remember seeing a post a while > back saying that using install instead of build was best (anyone - is > that true?). Yes, R CMD INSTALL --build is preferable to R CMD build --binary but R CMD build (without "--binary") builds a source package rather than a binary package. Uwe Ligges > > See you next week in Groton, > > Max > > > > Sorry, gmail seemed to have made an attachment out of my first attempted > > post. Trying again: > > -- > > At the encouragement of many at UseR, I'm trying to build my first real > package. I have no C/Fortran code, just plain old R code, so it should > be > rocket science. On a Linux box, I used package.skeleton() to create a > basic package containing just one "hello world" type of function. I > edited the DESCRIPTION file, changin the package name appropriately. I > edited the hello.Rd file. Upon running R CMD check hello, the only > warning had to do with the fact that src/ was empty (obviously I had no > source in such a simple package). I doubt this is a problem. > > I was able to install and use the package successfully on the Linux > system > from the .tar.gz file, so far so good! Next, on to Windows, where the > problem arose: > > I created a zip file from inside the package directory: > > zip -r ../hello.zip ./* > > When I moved this to my Windows machine and tried to install the package > > using the GUI, I received the following error: > > >>utils:::menuInstallLocal() > > Error in unpackPkg(pkgs[i], pkgnames[i], lib, installWithVers) : > malformed bundle DESCRIPTION file, no Contains field > > I only found one mention of this in my Google search, with no reply to > the > thread. The Contains field appears to be used for bundles, but I'm > trying > to create a package, not a bundle. This leads me to believe that a > simple > zipping of the package directory structure is not the correct format for > Windows. > > Needless to say, there appears to be wide agreement that making packages > requires precision, but fundamentally a package should (as described in > the > documentation) just be a collection of files and folders organized a > certain > way. If someone could point me to documentation I may have missed that > explains this, I would be grateful. > > Regards, > > Jay > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] comparing 2 odds ratios
Hi there, is there any way to compare 2 odds ratios? I have two tests that are supposed to detect a disease presence. So for each test, I can compute an odds ratio. My problem is how can I compare the 2 tests by testing whether the 2 odds ratios are the same? Appreciate __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Problem running one of the rgl demo scripts...
Afternoon folks: I'm getting a program crash when I try to run demo(rgl). The following error details result: RGUI caused a stack fault in module NVOPENGL.DLL at 017f:695280f0. Registers: EAX=0002 CS=017f EIP=695280f0 EFLGS=00010246 EBX=0001 SS=0187 ESP=00572000 EBP=004d1208 ECX=042f1f01 DS=0187 ESI=004d1208 FS=5d1f EDX=00442d84 ES=0187 EDI=042f1f3c GS=5d0e Bytes at CS:EIP: 53 56 8b 5c 24 0c 57 83 bb 9c 39 00 00 02 0f 84 Stack dump: 69541be5 004d1208 004d1208 0001 69541bef 0001 004d1208 0001 69541bef 0001 004d1208 0001 69541bef 0001 004d1208 0001 Setup details are: R version: 2.2.1 OS: win98se RGL file name: rgl_0.66.zip It appears to be gagging on an Nvidia opengl driver file, NVIDIA Compatible OpenGL ICD, version 4.12.01.0631. The video card is recorded as: 3DForce2 MX Series,NVIDIA GeForce2 MX (Ver 4.12.01.0631 ,9/20/2000) I also tried this with version 2.3.1 of R with the same results. Anyone have any thoughts or ideas on the subject? Has it occurred any place else? Is there a workaround or solution, or should I perhaps turf the package and forgo its abilities since it appears my system as it stands may not be able to support it? -- Brian Lunergan Nepean, Ontario Canada --- avast! Antivirus: Outbound message clean. Virus Database (VPS): 0626-0, 2006-06-26 Tested on: 2006-06-26 13:25:48 avast! is copyright (c) 2000-2006 ALWIL Software. http://www.avast.com __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to generate a figure using par( ) with some densityplot( )'s
Deepayan Sarkar wrote: > On 6/26/06, Sundar Dorai-Raj <[EMAIL PROTECTED]> wrote: > >> >> >> Amir Safari wrote: >> > >> > Hi Dear R users, >> > For a pair plotting, usaully we use par( ) function. Apparently it >> does not work anywhere. I want to have 3 plots in a single figure, >> like this: >> > par(mfrow=c(3,1)) >> > densityplot( a) >> > densityplot(b) >> > densityplot(c) >> > But it does not work. How is it possible to have such a figure >> with densityplot( ) in a single figure? >> > So many thanks for any help. >> > Amir Safari >> > >> > >> > >> >> Assuming you are talking about densityplot in lattice, then you are >> missing the point of lattice. You should try: >> >> library(lattice) >> set.seed(1) >> a <- rnorm(100) >> b <- rnorm(50) >> c <- rnorm(75) >> densityplot(~a + b + c, outer = TRUE, layout = c(3, 1)) > > > This only works if a, b and c are of the same length. The following > should work though: > > densityplot(~data | which, >data = make.groups(a, b, c)) > > -Deepayan > Hi, Deepayan, My mistake. This is clear in ?densityplot. However, there is no warning if the condition is not met and, apparently, recycling rules are applied. Thanks, --sundar __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problem running one of the rgl demo scripts...
Brian Lunergan wrote: > Afternoon folks: > > I'm getting a program crash when I try to run demo(rgl). The following > error details result: > > RGUI caused a stack fault in module NVOPENGL.DLL at 017f:695280f0. > Registers: > EAX=0002 CS=017f EIP=695280f0 EFLGS=00010246 > EBX=0001 SS=0187 ESP=00572000 EBP=004d1208 > ECX=042f1f01 DS=0187 ESI=004d1208 FS=5d1f > EDX=00442d84 ES=0187 EDI=042f1f3c GS=5d0e > Bytes at CS:EIP: > 53 56 8b 5c 24 0c 57 83 bb 9c 39 00 00 02 0f 84 > Stack dump: > 69541be5 004d1208 004d1208 0001 69541bef 0001 004d1208 0001 > 69541bef 0001 004d1208 0001 69541bef 0001 004d1208 0001 > > Setup details are: > > R version: 2.2.1 > OS: win98se > RGL file name: rgl_0.66.zip > > It appears to be gagging on an Nvidia opengl driver file, NVIDIA Compatible > OpenGL ICD, version 4.12.01.0631. The video card is recorded as: > > 3DForce2 MX Series,NVIDIA GeForce2 MX (Ver 4.12.01.0631 ,9/20/2000) > > I also tried this with version 2.3.1 of R with the same results. > > Anyone have any thoughts or ideas on the subject? Has it occurred any place > else? Is there a workaround or solution, or should I perhaps turf the > package and forgo its abilities since it appears my system as it stands may > not be able to support it? You could try a newer build, available on my web page (http://www.stats.uwo.ca/faculty/murdoch/software). If it dies the same way, you could perhaps try to diagnose what is going wrong and send a patch if it's an rgl bug. Given the age of your video driver (9/20/2000), you might be able to update it and fix a bug there. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] probably need to se sapply but i can't get it
Hi : I think I need to use sapply but I can't figure this out. Suppose I have two vectors : tempa ( 4, 6,10 ) and tempb ( 11,23 ,39 ) I want a function that returns 4:11,6:23 and 10:39 as vectors. I tried : sapply(1:length(tempa) function (z) seq(tempa[z],tempb[z]) but i got 3 really strange vectors back in the sense that the numbers in them did not make no sense to me. obviously, i must be doing something wrong. thanks a lot. mark __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] probably need to se sapply but i can't get it
On Mon, 2006-06-26 at 12:40 -0500, [EMAIL PROTECTED] wrote: > Hi : I think I need to use sapply but I can't figure this out. > > Suppose I have two vectors : tempa ( 4, 6,10 ) and tempb > ( 11,23 ,39 ) > > > I want a function that returns 4:11,6:23 and 10:39 as vectors. > > I tried : > > sapply(1:length(tempa) function (z) seq(tempa[z],tempb[z]) > > but i got 3 really strange vectors back in the sense that the numbers > in them did not make no sense to me. obviously, > i must be doing something wrong. thanks a lot. > >mark Mark, Try this using mapply(): tempa <- c(4, 6, 10) tempb <- c(11, 23, 39) > mapply(seq, from = tempa, to = tempb) [[1]] [1] 4 5 6 7 8 9 10 11 [[2]] [1] 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 [[3]] [1] 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [23] 32 33 34 35 36 37 38 39 You will get a list back in this case and you can then deal with the 3 vectors as you require. Each vector is a different length, so a list is about the only way to return them here. See ?mapply for more info. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Overlaying 2D kernel density plots on scatterplot matrix
Michael Hopkins skreiv: > The kernel density plots don¹t have to be very sophisticated i.e. > default settings and greyscale are fine we can work on details > later. What has stumped us so far is how you ‘attach’ the kernel > density results to the scatterplot results and then overlay them. > > Any ideas, links or code gratefully received. Here’s my suggestion¹: library(lattice) library(MASS) splom(~iris[1:4], panel=function(x,y) { xy=kde2d(x,y) xy.tr=con2tr(xy) panel.contourplot(xy.tr$x, xy.tr$y, xy.tr$z, subscripts=seq(nrow(xy.tr)), contour=TRUE, region=FALSE) panel.xyplot(x,y) } ) ¹ Which is basically Richard M. Heiberger’s solution to a similar query I had on this list earlier about a month ago: http://tolstoy.newcastle.edu.au/R/help/06/05/27184.html -- Karl Ove Hufthammer __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] probably need to se sapply but i can't get it
On Mon, 26 Jun 2006, [EMAIL PROTECTED] wrote: > Hi : I think I need to use sapply but I can't figure this out. > > Suppose I have two vectors : tempa ( 4, 6,10 ) and tempb > ( 11,23 ,39 ) > > > I want a function that returns 4:11,6:23 and 10:39 as vectors. > > I tried : > > sapply(1:length(tempa) function (z) seq(tempa[z],tempb[z]) > > but i got 3 really strange vectors back in the sense that the numbers in them > did not make no sense to me. obviously, > i must be doing something wrong. thanks a lot. An easier way to do this is mapply(seq,tempa,tempb) Your approach should have worked. It's hard to tell why it didn't because there are two syntax errors in your example so it clearly isn't actually what you did. Fixing them, I get > sapply(1:length(tempa), function (z) seq(tempa[z],tempb[z])) [[1]] [1] 4 5 6 7 8 9 10 11 [[2]] [1] 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 [[3]] [1] 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 [26] 35 36 37 38 39 as you wanted. -thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to generate a figure using par( ) with some densityplot( )'s
On 6/26/06, Sundar Dorai-Raj <[EMAIL PROTECTED]> wrote: > > Deepayan Sarkar wrote: > > On 6/26/06, Sundar Dorai-Raj <[EMAIL PROTECTED]> wrote: > > > >> > >> > >> Amir Safari wrote: > >> > > >> > Hi Dear R users, > >> > For a pair plotting, usaully we use par( ) function. Apparently it > >> does not work anywhere. I want to have 3 plots in a single figure, > >> like this: > >> > par(mfrow=c(3,1)) > >> > densityplot( a) > >> > densityplot(b) > >> > densityplot(c) > >> > But it does not work. How is it possible to have such a figure > >> with densityplot( ) in a single figure? > >> > So many thanks for any help. > >> > Amir Safari > >> > > >> > > >> > > >> > >> Assuming you are talking about densityplot in lattice, then you are > >> missing the point of lattice. You should try: > >> > >> library(lattice) > >> set.seed(1) > >> a <- rnorm(100) > >> b <- rnorm(50) > >> c <- rnorm(75) > >> densityplot(~a + b + c, outer = TRUE, layout = c(3, 1)) > > > > > > This only works if a, b and c are of the same length. The following > > should work though: > > > > densityplot(~data | which, > >data = make.groups(a, b, c)) > > > > -Deepayan > > > > Hi, Deepayan, > > My mistake. This is clear in ?densityplot. However, there is no warning > if the condition is not met and, apparently, recycling rules are applied. I'm aware of that, but the discrepancy in lengths is not easy to catch. Patches are welcome of course :-). Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] write.table & csv help
Hi, How can I produce the following output in .csv format using write.table function. for(i in seq(1:2)) { df <- rnorm(4, mean=0, sd=1) write.table(df,"C:/output.csv", append = TRUE, quote = FALSE, sep = ",", row.names = FALSE, col.names = TRUE) } Current O/p: x0.287816-0.81803-0.15231-0.25849x2.26831 0.8631740.2699140.181486 Desired output x1 x20.287816 2.26831-0.81803 0.863174-0.15231 0.269914-0.25849 0.181486 Thanx in advance Sachin - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] questions on local customized R distribution CD
Hello all! I hope this is the right place to post this question. The Oregon Chapter of ASA is working with local high school teachers as one of its outreaching program. We hope to use and test R as teaching tools. So, we think that a menu system (like R commander) with a few packages and a bit simplified installation instruction need to be developed. The main question is: 1) Is it OK to develop a customized CD-ROM distribution of R with pre-selected packages for high school? It will be distributed free, of course. Also, we plan to make it available from the chap web or deposit it to R-project, if requested. 2) If the customized distribution CD is OK, I also hope to get some technical help/advice from the core group members if any one is interested. Thank you very much in advance, Dongseok Choi, PhD The President of the Oregon Chapter of the ASA [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Inverse Error Function
Do any of the R libraries have an implementation of the Inverse Error Function (Inverse ERF)? ref: http://mathworld.wolfram.com/InverseErf.html http://functions.wolfram.com/GammaBetaErf/InverseErf/ Thanks, Nathan [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Inverse Error Function
Nathan Dabney wrote: > Do any of the R libraries have an implementation of the Inverse Error > Function (Inverse ERF)? > > ref: > http://mathworld.wolfram.com/InverseErf.html > http://functions.wolfram.com/GammaBetaErf/InverseErf/ > > Thanks, > Nathan > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Don't know of a built-in function, but you can try this: ## if you want the so-called 'error function' ## from ?pnorm erf <- function(x) 2 * pnorm(x * sqrt(2)) - 1 erf.inv <- function(x) qnorm((x + 1)/2)/sqrt(2) erf.inv(1) erf.inv(0) erf.inv(-1) erf.inv(erf(.25)) erf(erf.inv(.25)) erf.inv(.5) HTH, --sundar __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Inverse Error Function
Hi, You can use the following relation between standard normal probability distribution (\Phi) and error function: Erf(z) = 2 * \Phi(\sqrt(2) z) - 1 to evaluate invErf(x) in R as follows: invErf <- function(x) { # argument x must lie between -1 and 1 qnorm((1 + x) /2) / sqrt(2) } For example, > invErf(0.5) [1] 0.4769362762 Hope this helps, Ravi. -- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -- > -Original Message- > From: [EMAIL PROTECTED] [mailto:r-help- > [EMAIL PROTECTED] On Behalf Of Nathan Dabney > Sent: Monday, June 26, 2006 3:27 PM > To: R-help@stat.math.ethz.ch > Subject: [R] Inverse Error Function > > Do any of the R libraries have an implementation of the Inverse Error > Function (Inverse ERF)? > > ref: > http://mathworld.wolfram.com/InverseErf.html > http://functions.wolfram.com/GammaBetaErf/InverseErf/ > > Thanks, > Nathan > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting- > guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] questions on local customized R distribution CD
On 6/26/2006 3:14 PM, Dongseok Choi wrote: > Hello all! > > I hope this is the right place to post this question. > > The Oregon Chapter of ASA is working with local high school teachers as one > of its outreaching program. > We hope to use and test R as teaching tools. > So, we think that a menu system (like R commander) with a few packages and > a bit simplified installation instruction need to be developed. > > The main question is: > 1) > Is it OK to develop a customized CD-ROM distribution of R with pre-selected > packages for high school? > It will be distributed free, of course. > Also, we plan to make it available from the chap web or deposit it to > R-project, if requested. Generally the answer is yes, but read the GPL for the conditions. You do need to make the source code available. > > 2) > If the customized distribution CD is OK, I also hope to get some technical > help/advice from the core group members if any one is interested. See the R Installation and Administration manual first. It tells how to build R installers with non-standard included packages. Hopefully for 2.4.0 more customizations will be possible. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Tcl/Tk failing in JGR, but not in R for Mac OS X GUI
Dear r-helpers, I wonder if you can figure out why the following is working: > sessionInfo() Version 2.3.1 (2006-06-01) powerpc-apple-darwin8.6.0 attached base packages: [1] "tcltk" "methods" "stats" "graphics" "grDevices" "utils" "datasets" "base" other attached packages: igraph "0.1.2" > g <- graph.ring(10) > tkplot(g) Loading required package: tcltk Loading Tcl/Tk interface ... done [1] 1 An X window appears, and the graph can be interactively manipulated, as intended. But in JGR: > sessionInfo() Version 2.3.1 (2006-06-01) powerpc-apple-darwin8.6.0 attached base packages: [1] "graphics" "grDevices" "stats" "utils" "methods" [6] "base" other attached packages: igraphBHH2 JGR JavaGD rJava "0.1.2" "0.2-1" "1.4-2" "0.3-3" "0.4-3" > g <- graph.ring(10) > tkplot(g) Loading required package: tcltk Loading Tcl/Tk interface ... Error in fun(...) : Can't find a usable init.tcl in the following directories: @TCL_IN_FRAMEWORK@ @TCL_IN_FRAMEWORK@ This probably means that Tcl wasn't installed properly. Error: .onLoad failed in 'loadNamespace' for 'tcltk' Error in tkplot(g) : tcl/tk library not available _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Some tcltk-related packages not loading (OS X)
Dear r helpers, In my exploration of the tcltk facilities of R I've had some success but some failures, and wonder if someone could point me to a solution. To begin: ** > sessionInfo() Version 2.3.1 (2006-06-01) powerpc-apple-darwin8.6.0 attached base packages: [1] "tcltk" "methods" "stats" "graphics" "grDevices" "utils" "datasets" "base" other attached packages: igraph "0.1.2" ** A success: ** > library(tcltk) > tt <- tktoplevel() > tkpack(txt.w <- tktext(tt)) > tkinsert(txt.w, "0.0", "plot(1:10)") > > eval.txt <- function() +eval(parse(text=tclvalue(tkget(txt.w, "0.0", "end" > tkpack(but.w <- tkbutton(tt,text="Submit", command=eval.txt)) > > tkdestroy(tt) ** An interactive session ran successfully. One failure: ** > library(gtkDevice) Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library '/Library/Frameworks/R.framework/ Versions/2.3/Resources/library/gtkDevice/libs/ppc/gtkDevice.so': dlopen(/Library/Frameworks/R.framework/Versions/2.3/Resources/ library/gtkDevice/libs/ppc/gtkDevice.so, 6): Symbol not found: _gtk_main_quit Referenced from: /Library/Frameworks/R.framework/Versions/2.3/ Resources/library/gtkDevice/libs/ppc/gtkDevice.so Expected in: flat namespace Error in library(gtkDevice) : .First.lib failed for 'gtkDevice' ** and another: ** > library(tkrplot) Error in structure(.External("dotTcl", ..., PACKAGE = "tcltk"), class = "tclObj") : [tcl] image not found NSCreateObjectFileImageFromFile() error: not a Mach-O MH_BUNDLE file. Error in library(tkrplot) : .First.lib failed for 'tkrplot' ** I ran > installed.packages() the two relevant lines are: Package LibPath Version PriorityBundle gtkDevice "gtkDevice" "/Library/Frameworks/R.framework/Versions/2.3/ Resources/library" "1.9-4" NA NA tkrplot "tkrplot" "/Library/Frameworks/R.framework/Versions/2.3/ Resources/library" "0.0-14"NA NA ** I tried reinstalling gtkDevice from source, and got: ** > trying URL 'http://lib.stat.cmu.edu/R/CRAN/src/contrib/ gtkDevice_1.9-4.tar.gz' Content type 'application/x-gzip' length 41475 bytes opened URL == downloaded 40Kb WARNING: ignoring environment value of R_HOME * Installing *source* package 'gtkDevice' ... checking for gtk-config... no checking for gtk12-config... no ERROR: Cannot find gtk-config. ** Removing '/Library/Frameworks/R.framework/Versions/2.3/Resources/ library/gtkDevice' ** Restoring previous '/Library/Frameworks/R.framework/Versions/2.3/ Resources/library/gtkDevice' The downloaded packages are in /private/tmp/RtmpjNWS1J/downloaded_packages ERROR: configuration failed for package 'gtkDevice' ** I tried installing tkrplot from source, and that worked! ** trying URL 'http://lib.stat.cmu.edu/R/CRAN/src/contrib/ tkrplot_0.0-14.tar.gz' Content type 'application/x-gzip' length 38339 bytes opened URL == downloaded 37Kb WARNING: ignoring environment value of R_HOME * Installing *source* package 'tkrplot' ... configure: creating ./config.status config.status: creating src/Makevars ** libs ** arch - ppc gcc-4.0 -arch ppc -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/ppc -I/usr/local/ include -I/usr/local/include -I/usr/local/include -fPIC -fno- common -g -O2 -std=gnu99 -c tcltkimg.c -o tcltkimg.o gcc-4.0 -arch ppc -flat_namespace -bundle -undefined suppress -L/usr/ local/lib -o tkrplot.so tcltkimg.o -L/usr/local/lib -ltcl8.4 -L/usr/ local/lib -ltk8.4 -L/usr/X11R6/lib -lX11 -L/Library/Frameworks/ R.framework/Resources/lib/ppc -lR ** R ** help >>> Building/Updating help pages for package 'tkrplot' Formats: text html latex example TkRplot texthtmllatex example ** building package indices ... * DONE (tkrplot) The downloaded packages are in /private/tmp/RtmpjNWS1J/downloaded_packages ** But: ** > library(tkrplot) Loading required packa
[R] princomp and prcomp confusion
When I look through archives at https://stat.ethz.ch/pipermail/r-help/2003-October/040525.html I see this: Liaw, Andy wrote: >In the `Detail' section of ?princomp: > >princomp only handles so-called Q-mode PCA, that is feature extraction of >variables. If a data matrix is supplied (possibly via a formula) it is >required that there are at least as many units as variables. For R-mode PCA >use prcomp. > It doesn't appear that anyone disputed the accuracy of it. My current installation (version.string Version 2.3.1 (2006-06-01)) says in the detail of princomp 'princomp' only handles so-called R-mode PCA, that is feature extraction of variables. If a data matrix is supplied (possibly via a formula) it is required that there are at least as many units as variables. For Q-mode PCA use 'prcomp'. I've not been following principal components and have only recently had a use for that methodology. Am I to assume that the later version is the correct one? I thought I'd worked out what the distinction between R-mode and Q-mode was, but now I'm as confused as ever. best -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_Middle minds discuss events (:_~*~_:)Small minds discuss people (_)-(_) . Anon ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] compare odds ratios
Hi there, is there any way to compare 2 odds ratios? I have two tests that are supposed to detect a disease presence. So for each test, I can compute an odds ratio. My problem is how can I compare the 2 tests by testing whether the 2 odds ratios are the same? Appreciate __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Griddy-Gibbs sampler
Hey everyone, I have read the paper by Ritter and Tanner(1992) on Griddy-Gibbs sampler and I am trying to implement it in R without much luck. I was wondering if anyone had used this or could point me to any example code. Thanks, Liz - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Some tcltk-related packages not loading (OS X)
Michael Kubovy <[EMAIL PROTECTED]> writes: > Dear r helpers, > > In my exploration of the tcltk facilities of R I've had some success > but some failures, and wonder if someone could point me to a > solution. To begin: > > ** > > sessionInfo() > Version 2.3.1 (2006-06-01) > powerpc-apple-darwin8.6.0 > > attached base packages: > [1] "tcltk" "methods" "stats" "graphics" "grDevices" > "utils" "datasets" "base" > > other attached packages: > igraph > "0.1.2" > ** > A success: > ** > > library(tcltk) > > tt <- tktoplevel() > > tkpack(txt.w <- tktext(tt)) > > > tkinsert(txt.w, "0.0", "plot(1:10)") > > > > > eval.txt <- function() > +eval(parse(text=tclvalue(tkget(txt.w, "0.0", "end" > > tkpack(but.w <- tkbutton(tt,text="Submit", command=eval.txt)) > > > > > tkdestroy(tt) > ** > An interactive session ran successfully. One failure: > ** > > library(gtkDevice) gtk is not related to tcltk. They are essentially different GUI programming interfaces. > ** > trying URL 'http://lib.stat.cmu.edu/R/CRAN/src/contrib/ > tkrplot_0.0-14.tar.gz' > Content type 'application/x-gzip' length 38339 bytes > opened URL > == > downloaded 37Kb > > WARNING: ignoring environment value of R_HOME > * Installing *source* package 'tkrplot' ... > configure: creating ./config.status > config.status: creating src/Makevars > ** libs > ** arch - ppc > gcc-4.0 -arch ppc -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include/ppc -I/usr/local/ > include -I/usr/local/include -I/usr/local/include -fPIC -fno- > common -g -O2 -std=gnu99 -c tcltkimg.c -o tcltkimg.o > gcc-4.0 -arch ppc -flat_namespace -bundle -undefined suppress -L/usr/ > local/lib -o tkrplot.so tcltkimg.o -L/usr/local/lib -ltcl8.4 -L/usr/ > local/lib -ltk8.4 -L/usr/X11R6/lib -lX11 -L/Library/Frameworks/ > R.framework/Resources/lib/ppc -lR > ** R > ** help > >>> Building/Updating help pages for package 'tkrplot' > Formats: text html latex example >TkRplot texthtmllatex example > ** building package indices ... > * DONE (tkrplot) > > The downloaded packages are in > /private/tmp/RtmpjNWS1J/downloaded_packages > ** > But: > ** > > library(tkrplot) > Loading required package: tcltk > Loading Tcl/Tk interface ... done > Error in structure(.External("dotTcl", ..., PACKAGE = "tcltk"), class > = "tclObj") : > [tcl] image not found > NSCreateObjectFileImageFromFile() error: not a Mach-O MH_BUNDLE file. > Error in library(tkrplot) : .First.lib failed for 'tkrplot' Presumably, this means that the "load" command in Tcl is not happy loading tkrplot.so as generated by the 2nd gcc-4.0 command above. For a non-Mac-guru like me this raises a few questions: Is .so really the right extension? Is a special processing step needed for Mac OSX? However, better leave this for real Mac gurus... -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Passing arguments from a function within another function
Hi all, I have a function getSomeData() that is called from command line - getSomeData(id='1240'). The function getSomeData() calls another function getData that needs the exact same argument passed to getSomeData(). I am using the function call getData(paste(names(args[1]), "=", sQuote(args[[1]]))). The argument passed is- id='1240'. The problem is that in getData(), it treats the whole thing "id='1240'" as one arguments i.e. for getData args[[1]] is "id='1240'". Hence, I am unable to extract the name id and the value of id separately. Beacuse of this, I am not able to generate the SQL query select * from table where id = '1240'. Thank you. Aarti __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Plylogenetic analysis
On Mon, 2006-06-26 at 10:59 -0300, Erica Baron wrote: > Dear coleges, > How to use the genotype from microsatelite markers > from many different populations to construct a > tridimensional phylogenetic tree with R? Any > suggestions? > Thank you very much! > Baron, Erica Hi Erica, I know nothing about phylogenetics, but perhaps you could help yourself by checking out the CRAN Task View on Genetics, e.g.: http://www.stats.bris.ac.uk/R/src/contrib/Views/Genetics.html You could also do: RSiteSearch("phylogenetic tree") If that doesn't get you anywhere, then you might get further help from the list if you post some example data and perhaps a link to a image of the type of plot you are wanting to reproduce. Some kind soul might then be able to help... Gav __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] looking for a more efficient R code.
Dear R-users I have four simple linear models, which are all in the form of a*X+b The estimated parameter vectors are a <- c(1,2,3,4) b <- c(4,3,2,1) My goal is to draw a plot where x-axis is X (range from -100 to 100) and y-axis is the sum of all four linear models X <- seq(-100,100, length=1) plot(X, sum of the four linear functions) I started with a function for summing summing <- function(a,b) {temp <-0; for (i in 1:length(a)) temp <- temp + a[i]*X+b[i] } plot(X, summing(a,b)) I am a R beginner. I am looking for a more efficient R code. Any help or advice will be appreciated. Taka, __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Effect size in mixed models
Hi Spencer, what you're describing now seems to me to be similar to the idea of intra-class correlation. I have previously used the relative and absolute amounts of variance represented at different hierarchical levels of random effects, and they seemed to me to be easy to interpret and useful, although I used method of moments estimators instead of ML. This ease of interpretation and utility is especially true when the random effects structure matches the physical layout of a sample, e.g., multiple measurements within trees within plots within stands within forests etc. Sadly I cannot see how to cleanly generalize the principle to situations of crossed random effects. Also, as Goldstein et al point out in a nice paper in Understanding Statistics (2002): "Partitioning variation in multilevel models", random covariates also complicate the picture substantially. Cheers Andrew On Thu, Jun 22, 2006 at 05:23:52PM -0700, Spencer Graves wrote: > I just learned that my earlier suggestion was wrong. It's better to > compute the variance of the predicted or fitted values and compare those > with the estimated variance components. > > To see how to do this, consider the following minor modification of > an example in the "lme" documentation: > > fm1. <- lme(distance ~ age, data = Orthodont, random=~1) > fm2. <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1) > > # str(fm1.) suggested the following: > > var(fm2.$fitted[, "fixed"]-fm1.$fitted[, "fixed"]) > [1] 1.312756 > > VarCorr(fm1.)[, 1] > (Intercept)Residual > "4.472056" "2.049456" > > VarCorr(fm2.)[, 1] > (Intercept)Residual > "3.266784" "2.049456" > > In this example, the subject variance without considering "Sex" was > 4.47 but with "Sex" in the model, it dropped to 3.27, while the Residual > variance remained unchanged at 2.05. The difference between > fm2.$fitted[, "fixed"] and fm1.$fitted[, "fixed"] is the change in the > predictions generated by the addition of "Sex" to the model. The > variance of that difference was 1.31. Note that 3.27 + 1.31 = 4.58, > which is moderately close to 4.47. > > In sum, I think we can get a reasonable estimate of the size of an > effect from the variance of the differences in the "fixed" portion of > the fitted model. > > Comments? > Hope this helps. > Spencer Graves > > Spencer Graves wrote: > > You have asked a great question: It would indeed be useful to > > compare the relative magnitude of fixed and random effects, e.g. to > > prioritize efforts to better understand and possibly manage processes > > being studied. I will offer some thoughts on this, and I hope if there > > are errors in my logic or if someone else has a better idea, we will > > both benefit from their comments. > > > > The ideal might be an estimate of something like a mean square for > > a particular effect to compare with an estimated variance component. > > Such mean squares were a mandatory component of any analysis of variance > > table prior to the (a) popularization of generalized linear models and > > (b) availability of software that made it feasible to compute maximum > > likelihood estimates routinely for unbalanced, mixed-effects models. > > However, anova(lme(...)) such mean squares are for most purposes > > unnecessary cluster in a modern anova table. > > > > To estimate a mean square for a fixed effect, consider the > > following log(likelihood) for a mixed-effects model: > > > > lglk = (-0.5)*(n*log(2*pi*var.e)-log(det(W)) + > > t(y-X%*%b)%*%W%*%(y-X%*%b)/var.e), > > > > where n = the number of observations, > > > > b = the fixed-effect parameter variance, > > > > and the covariance matrix of the residuals, after integrating out the > > random effects is var.e*solve(W). In this formulation, the matrix "W" > > is a function of the variance components. Since they are not needed to > > compute the desired mean squares, they are suppressed in the notation here. > > > > Then, the maximum likelihood estimate of > > > > var.e = SSR/n, > > > > where SSR = t(y-X%*%b)%*%W%*%(y-X%*%b). > > > > Then > > > > mle.lglk = (-0.5)*(n*(log(2*pi*SSR/n)-1)-log(det(W))). > > > > Now let > > > > SSR0 = this generalized sum of squares of residuals (SSR) without > > effect "1", > > > > and > > > > SSR1 = this generalized SSR with this effect "1". > > > > If I've done my math correctly, then > > > > D = deviance = 2*log(likelihood ratio) > > = (n*log(SSR0/SSR1)+log(det(W1)/det(W0))) > > > > For roughly half a century, a major part of "the analysis of > > variance" was the Pythagorean idea that the sum of squares under H0 was > > the sum of squares under H1 plus the sum of squares for effect "1": > > > > SSR0 = SS1 + SSR1. > > > > Whence, > > > > exp((D/n)-log(det(W1)/det(W0))) = 1+SS1/SSR1. > >
Re: [R] looking for a more efficient R code.
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > On Behalf Of Taka Matzmoto > Sent: Monday, June 26, 2006 5:21 PM > To: r-help@stat.math.ethz.ch > Subject: [R] looking for a more efficient R code. > > Dear R-users > > I have four simple linear models, which are all in the form of a*X+b > The estimated parameter vectors are > > a <- c(1,2,3,4) > b <- c(4,3,2,1) > > My goal is to draw a plot where x-axis is X (range from -100 to 100) and > y-axis is the sum of > all four linear models > > X <- seq(-100,100, length=1) > plot(X, sum of the four linear functions) > > I started with a function for summing > > summing <- function(a,b) > {temp <-0; > for (i in 1:length(a)) > temp <- temp + a[i]*X+b[i] > } > > plot(X, summing(a,b)) > > I am a R beginner. I am looking for a more efficient R code. > > Any help or advice will be appreciated. > > Taka, > Taka, I won't claim more efficient, that is for you to decide. But you might try something like: plot(x, colSums(t(x %*% t(b)) + a)) Dan Daniel Nordlund Bothell, WA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] looking for a more efficient R code.
try this: a <- c(1,2,3,4) b <- c(4,3,2,1) X <- seq(-100,100, length=1) z <- colSums(sapply(X,function(x)a*x+b)) plot(X, z, type='l') On 6/26/06, Taka Matzmoto <[EMAIL PROTECTED]> wrote: > > Dear R-users > > I have four simple linear models, which are all in the form of a*X+b > The estimated parameter vectors are > > a <- c(1,2,3,4) > b <- c(4,3,2,1) > > My goal is to draw a plot where x-axis is X (range from -100 to 100) and > y-axis is the sum of > all four linear models > > X <- seq(-100,100, length=1) > plot(X, sum of the four linear functions) > > I started with a function for summing > > summing <- function(a,b) > {temp <-0; > for (i in 1:length(a)) > temp <- temp + a[i]*X+b[i] > } > > plot(X, summing(a,b)) > > I am a R beginner. I am looking for a more efficient R code. > > Any help or advice will be appreciated. > > Taka, > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > -- Jim Holtman Cincinnati, OH +1 513 646 9390 (Cell) +1 513 247 0281 (Home) What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] looking for a more efficient R code.
Little algebra will convince you that your 'summing' function is just equal to: sum(a) + sum(b)*X So, it is very difficult to get it any faster than: plot(X, sum(a)+sum(b)*X) And, by the way, most of the execution time is spent plotting, not computing the average: > system.time({y1 <- summing(a,b)}) [1] 0.002 0.000 0.001 0.000 0.000 > system.time({y2 = sum(a)+sum(b)*X}) [1] 0 0 0 0 0 > all.equal(y1,y2) [1] TRUE > system.time(plot(X,y2)) [1] 0.019 0.002 0.051 0.000 0.000 > Gardar On Mon, 2006-06-26 at 17:21, Taka Matzmoto wrote: > Dear R-users > > I have four simple linear models, which are all in the form of a*X+b > The estimated parameter vectors are > > a <- c(1,2,3,4) > b <- c(4,3,2,1) > > My goal is to draw a plot where x-axis is X (range from -100 to 100) and > y-axis is the sum of > all four linear models > > X <- seq(-100,100, length=1) > plot(X, sum of the four linear functions) > > I started with a function for summing > > summing <- function(a,b) > {temp <-0; > for (i in 1:length(a)) > temp <- temp + a[i]*X+b[i] > } > > plot(X, summing(a,b)) > > I am a R beginner. I am looking for a more efficient R code. > > Any help or advice will be appreciated. > > Taka, > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Robustness of linear mixed models
Hello, with 4 different linear mixed models (continuous dependent) I find that my residuals do not follow the normality assumption (significant Shapiro-Wilk with values equal/higher than 0.976; sample sizes 750 or 1200). I find, instead, that my residuals are really well fitted by a t distribution with dofs' ranging, in the different datasets, from 5 to 12. Should this be considered such a severe violation of the normality assumption as to make model-based inferences invalid? Thanks a lot, Bruno __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] related to my previous sapply question]
in my previous post in which i asked about creating sequences from two vectors of numbers, all suggestions worked. tradevectors<-mapply(seq,from=tempa,to=tempb) or tradevectors<-sapply(1:length(tempa),function(x) seq(tempa[x],tempb[x]) >both return a list with 3 components. the problem is that i want to take these 3 sequences and use them as the indices of two other vectors, X and Y and mutiply them ( element by element ) >so, i tried > >temp<-sapply(1:length(tradevectors),function(i)X[tradevectors[[i]]]*Y[tradevectors[[i]]] basically, the sequence output from the previous command are indices to two vectors that i want to multiply ( element by element ). but, the message i get is that i cannot coerce list object to double. i looked up the info on unlist, but that just makes long vector. i need 3 vectors. thanks __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Passing arguments from a function within another function
See: http://tolstoy.newcastle.edu.au/R/help/06/06/29301.html On 6/26/06, Aarti Dahiya <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a function getSomeData() that is called from command line - > getSomeData(id='1240'). The function getSomeData() calls another function > getData that needs the exact same argument passed to getSomeData(). I am > using the function call getData(paste(names(args[1]), "=", > sQuote(args[[1]]))). The argument passed is- id='1240'. > > The problem is that in getData(), it treats the whole thing "id='1240'" as > one arguments i.e. for getData args[[1]] is "id='1240'". Hence, I am unable > to extract the name id and the value of id separately. Beacuse of this, I > am not able to generate the SQL query select * from table where id = '1240'. > > Thank you. > > Aarti > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] almost figured it out but failed
I used RSearchSite and found out about using matrix(unlist(thelist),nrow=length(thelist),byrow=TRUE) but then i realized that I can't use this because each component of the list can be a different length so the matrix would have to have variable column lengths which makes no sense. thanks for any suggestions. mark __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] related to my previous sapply question]
On Mon, 2006-06-26 at 20:46 -0500, [EMAIL PROTECTED] wrote: > in my previous post in which i asked about creating sequences > from two vectors of numbers, all suggestions worked. > > tradevectors<-mapply(seq,from=tempa,to=tempb) > > or > > tradevectors<-sapply(1:length(tempa),function(x) seq(tempa[x],tempb[x]) > > >both return a list with 3 components. > > the problem is that i want to take these 3 sequences and > > use them as the indices of two other vectors, X and Y and mutiply them ( > element by element ) > > > >so, i tried > > > >temp<-sapply(1:length(tradevectors),function(i)X[tradevectors[[i]]]*Y[tradevectors[[i]]] > > > basically, the sequence output from the previous command are > indices to two vectors that i want to multiply ( element > by element ). > > but, the message i get is that i cannot coerce list object to double. > > i looked up the info on unlist, but that just > makes long vector. i need 3 vectors. How about something like this: tempa <- c(4, 6, 10) tempb <- c(11, 23, 39) tradevectors <- mapply(seq, from = tempa, to = tempb) > tradevectors [[1]] [1] 4 5 6 7 8 9 10 11 [[2]] [1] 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 [[3]] [1] 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [23] 32 33 34 35 36 37 38 39 X <- seq(2, 80, 2) Y <- 1:40 > X [1] 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 [23] 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 > Y [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [23] 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 > lapply(tradevectors, function(x) X[x] * Y[x]) [[1]] [1] 32 50 72 98 128 162 200 242 [[2]] [1] 72 98 128 162 200 242 288 338 392 450 512 578 648 [14] 722 800 882 968 1058 [[3]] [1] 200 242 288 338 392 450 512 578 648 722 800 882 968 [14] 1058 1152 1250 1352 1458 1568 1682 1800 1922 2048 2178 2312 2450 [27] 2592 2738 2888 3042 For example, the first value in [[1]] is 32, which is: X[4] * Y[4]# The '4' comes from tradevectors[[1]][1] which is: 8 * 4 The other list elements are similarly constructed. You can use lapply() when you want to apply functions to individual list elements (in this case vectors) as you traverse the list tree. See ?lapply HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] reshaping data.frame question
Thanks, this is not what what I meant. I need to reshape the original dataframe that I can access p_f[X] for numerical X. Maybe I was not clear enough. The problem really is that X starts at 0. Note that in my example changing the row names to 0:2 does not have the desired effect. jim holtman wrote: > You need to specify the row/column name as character: > >> y > X1 X2 X3 X4 > 0 0.1 0.1 0.1 0.1 > 1 0.2 0.2 0.2 0.2 > 2 0.3 0.3 0.3 0.3 > >> y[,'X3'] > [1] 0.1 0.2 0.3 >> y['0','X3'] > [1] 0.1 > > > > > On 6/26/06, Matthias Braeunig <[EMAIL PROTECTED]> wrote: >> > Dear R-helpers, > > > my data.frame is of the form > > x <- data.frame( f=gl(4,3), X=rep(0:2,4), p=c(.1,.2,.3)) > x > f X p > 1 1 0 0.1 > 2 1 1 0.2 > 3 1 2 0.3 > 4 2 0 0.1 > 5 2 1 0.2 > 6 2 2 0.3 > 7 3 0 0.1 > 8 3 1 0.2 > 9 3 2 0.3 > 10 4 0 0.1 > 11 4 1 0.2 > 12 4 2 0.3 > > which tabulates some values p(X) for several factors f. > > Now I want to put it in "wide" format, so that factor levels appear as > column heads. Note also that X starts from zero. It would be nice if I > could simply access p_f[X==0] as f[0]. How can I possibly do that? > > (The resilting object does not have to be a data.frame. As there are > only numeric values, also a matrix would do.) > > I tried the following > > y<-unstack(x,form=p~f) > row.names(y) <- 0:2 > y > X1 X2 X3 X4 > 0 0.1 0.1 0.1 0.1 > 1 0.2 0.2 0.2 0.2 > 2 0.3 0.3 0.3 0.3 > > Now, how to access X3[0], say? > > Maybe reshape would be the right tool, but I could not figure it out. > > I appreciate your help. Thanks! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Adding elements of matrices of different dimensions
If I have two matrices: > a<-matrix(1:5,ncol=1) [,1] [1,]1 [2,]2 [3,]3 [4,]4 [5,]5 > b<-matrix(1:50,ncol=10) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]16 11 16 21 26 31 36 4146 [2,]27 12 17 22 27 32 37 4247 [3,]38 13 18 23 28 33 38 4348 [4,]49 14 19 24 29 34 39 4449 [5,]5 10 15 20 25 30 35 40 4550 How can I add a[1,1] to each column in the first row of b. and the then add a[2,1] to each column in second row of b and so on. I know there must be a way to use the apply function or nested for loops but I can't seem to get it working in R. thanks, michael [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html