Re: [R] running R-code outside of R
The user of your R script sees only the outputs you create. The R source is hidden. HTH, Jim Porzak Responsys, Inc. San Francisco, CA http://www.linkedin.com/in/jimporzak On Tue, Jun 24, 2008 at 9:33 PM, Esmail Bonakdarian <[EMAIL PROTECTED]> wrote: > Jim Porzak wrote: > >> Roger, >> >> Following on to Spencer's comments, we have had some success using RWui >> http://rwui.cryst.bbk.ac.uk/ >> to build web enabled versions of (non-interactive) R programs. >> >> Advantage is your users only need a browser. No exe to install. Downside >> is >> you need to have a web server accessible to your user base. We're using a >> very simple Tomcat setup within our firewall to provide access to canned R >> scripts. >> > > Hi, > > This sounds interesting, I have one question though (I quickly looked at > the page but didn't find an obvious answer) > > Would the R script that is being run be hidden from the user, or would the > user be able to view/download/save the R source code - or could it be > hidden > so they just run the code, but never see it? > > Esmail > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Incompatible methods ("+.Date", "Ops.difftime") for "+"
You can specify units= to be extra sure: d <- difftime(Sys.Date() + 1, Sys.Date(), units = "mins") as.numeric(d, units = "days") On Wed, Jun 25, 2008 at 12:23 AM, Richard M. Heiberger <[EMAIL PROTECTED]> wrote: > I received a warning about incompatible methods that I don't understand. > The workaround in this example is simple. > > What is the reason that these methods are seen as incompatible? > Is there some dangerous consequence of my as.numeric() workaround? > Can a fix to the code base, perhaps similar to my workaround, make this > warning no longer necessary? > > I am using R 2.7.0 on Windows. > version.string R version 2.7.0 (2008-04-22) > > Thanks > > Rich > > > > xlim <- as.Date(c("2005-04-09", "2007-09-07")) > dx <- diff(xlim) > xlim + c(-.02, .02)*dx ## correct answer and warning message > xlim + as.numeric(c(-.02, .02)*dx) ## correct answer > >> xlim <- as.Date(c("2005-04-09", "2007-09-07")) >> xlim > [1] "2005-04-09" "2007-09-07" >> dx <- diff(xlim) >> dx > Time difference of 881 days >> xlim + c(-.02, .02)*dx ## correct answer and warning message > [1] "2005-03-22" "2007-09-24" > Warning message: > Incompatible methods ("+.Date", "Ops.difftime") for "+" >> xlim + as.numeric(c(-.02, .02)*dx) ## correct answer > [1] "2005-03-22" "2007-09-24" >> > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] running R-code outside of R
Jim Porzak wrote: Roger, Following on to Spencer's comments, we have had some success using RWui http://rwui.cryst.bbk.ac.uk/ to build web enabled versions of (non-interactive) R programs. Advantage is your users only need a browser. No exe to install. Downside is you need to have a web server accessible to your user base. We're using a very simple Tomcat setup within our firewall to provide access to canned R scripts. Hi, This sounds interesting, I have one question though (I quickly looked at the page but didn't find an obvious answer) Would the R script that is being run be hidden from the user, or would the user be able to view/download/save the R source code - or could it be hidden so they just run the code, but never see it? Esmail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Incompatible methods ("+.Date", "Ops.difftime") for "+"
I received a warning about incompatible methods that I don't understand. The workaround in this example is simple. What is the reason that these methods are seen as incompatible? Is there some dangerous consequence of my as.numeric() workaround? Can a fix to the code base, perhaps similar to my workaround, make this warning no longer necessary? I am using R 2.7.0 on Windows. version.string R version 2.7.0 (2008-04-22) Thanks Rich xlim <- as.Date(c("2005-04-09", "2007-09-07")) dx <- diff(xlim) xlim + c(-.02, .02)*dx ## correct answer and warning message xlim + as.numeric(c(-.02, .02)*dx) ## correct answer > xlim <- as.Date(c("2005-04-09", "2007-09-07")) > xlim [1] "2005-04-09" "2007-09-07" > dx <- diff(xlim) > dx Time difference of 881 days > xlim + c(-.02, .02)*dx ## correct answer and warning message [1] "2005-03-22" "2007-09-24" Warning message: Incompatible methods ("+.Date", "Ops.difftime") for "+" > xlim + as.numeric(c(-.02, .02)*dx) ## correct answer [1] "2005-03-22" "2007-09-24" > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with cube3d cube size
Mark Kimpel gmail.com> writes: > > I'm using the command below on an open3d() object to create a shaded > cube. Changes to myScalingFactor do not effect changes in the size of > the cube. What is the correct approach? Mark how about scale3d() ? shade3d(translate3d(scale3d(cube3d(),5,5,5),-6,1,-1),col="blue", alpha = 0.2) shade3d(translate3d(cube3d(),-6,1,-1),col="green", alpha = 0.2) shade3d(translate3d(scale3d(cube3d(),10,10,10),-6,1,-1),col="red", alpha = 0.2) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with cube3d cube size
Mark Kimpel wrote: I'm using the command below on an open3d() object to create a shaded cube. Changes to myScalingFactor do not effect changes in the size of the cube. What is the correct approach? Mark shade3d(translate3d(cube3d(identityMatrix() * myScalingFactor),-6,1,-1),col="green", alpha = 0.2) Homogeneous coordinates are strange. Your identityMatrix() * myScalingFactor produces a matrix that has the same effect as not multiplying. You need scaleMatrix(myScalingFactor, myScalingFactor, myScalingFactor) to get a size change. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error message: Bad value
Thank you for the response. I was doing a basic operation with a small dataset and am (fortunately for me) unable to reproduce the error. After restarting R, without shutting down anything else, there was no error. I thought I would post, however, since 2 others had reported the same problem in the past year. Toby - Original Message - From: "Duncan Murdoch" <[EMAIL PROTECTED]> To: "Toby Gass" <[EMAIL PROTECTED]> Cc: Sent: Tuesday, June 24, 2008 6:27 PM Subject: Re: [R] Error message: Bad value | On 24/06/2008 3:12 PM, Toby Gass wrote: | > Dear R help, | > | > In the middle of my session, I started receiving the error | > message "bad value" | > regardless of what I entered. I had to close R and restart | > it. When the error | > occurred, I was creating basic lattice plots, with no other | > add-on packages running. | > I am running R through John Fox's XEmacs interface, XEmacs | > version | > 21.4.20 on a Windows XP Pro machine with 2 GB of RAM. I | > have had | > no other problems. I've found 2 similar reports in the | > R-help | > archive, | > neither of which was resolved; one of the earlier posters | > was running Linux. | | That message is probably being printed in response to memory corruption. | | > platform i386-pc-mingw32 | > arch i386 | > os mingw32 | > system i386, mingw32 | > status | > major 2 | > minor 6.2 | | That version is a little old; 2.7.1 was just released. If you can make | the error reproducible in a current version (or even in 2.6.2), it would | be very helpful to post the recipe, and it will probably get fixed. | | Duncan Murdoch | | | > year 2008 | > month 02 | > day 08 | > svn rev 44383 | > language R | > version.string R version 2.6.2 (2008-02-08) | > | > Previous reports are found here: | > http://tolstoy.newcastle.edu.au/R/e4/help/08/01/0686.html | > http://tolstoy.newcastle.edu.au/R/e2/help/07/06/19095.html | > | > I do not need a response, unless there is a preventative | > measure, | > but thought I would bring this to your attention. | > | > Thank you, | > | > Toby | > | > Toby Gass | > Graduate Degree Program in Ecology | > Department of Forest, Rangeland, and Watershed Stewardship | > Warner College of Natural Resources | > Colorado State University | > Fort Collins, CO 80523 | > | > __ | > R-help@r-project.org mailing list | > https://stat.ethz.ch/mailman/listinfo/r-help | > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html | > and provide commented, minimal, self-contained, reproducible code. | __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Average of Two Matrices
What about z <- (x + y) / 2 Gundala Viswanath wrote: Hi, I have two matrices x and y (same dimensions). How can I compute the average of "x" and "y" for each coordinate to form a new average matrix "z" ? - Gundala Viswanath Jakarta - Indonesia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Average of Two Matrices
Hi, I have two matrices x and y (same dimensions). How can I compute the average of "x" and "y" for each coordinate to form a new average matrix "z" ? - Gundala Viswanath Jakarta - Indonesia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help with cube3d cube size
I'm using the command below on an open3d() object to create a shaded cube. Changes to myScalingFactor do not effect changes in the size of the cube. What is the correct approach? Mark shade3d(translate3d(cube3d(identityMatrix() * myScalingFactor),-6,1,-1),col="green", alpha = 0.2) -- Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, & Mobile & VoiceMail (317) 663-0513 Home (no voice mail please) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] heatmap and continuous variable
Hello Hans, Do you need *both* a categorical *and* a continuous variable, or just a continuous variable? -Greg On 6/24/08 4:51PM , "Hans-Ulrich Klein" <[EMAIL PROTECTED]> wrote: > Dear All, > > I want to plot a heat map with annotated columns. Both functions heatmap > (stats) and heatmap.2 (gplots) can plot a horizontal side bar that can > be used to visualize a categorical variable. In addition to a > categorical variable, I would like to visualize a continuous variable. > This could be done by small bars, a curve or simply numbers above the > columns. (The Sample names are already located at the bottom.) > > Does someone have example code for this or a similar problem? Is this so > special that I have to get down to the lattice package? > > Thank you, > Hans-Ulrich -- Gregory R. Warnes, Ph.D Program Director Center for Computational Arts, Sciences, and Engineering University of Rochester Tel: 585-273-2794 Fax: 585-276-2097 Email: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Hessian in box-constraint problem - concern OPTIM function
Hello Mr. Graves, Hello all useRs, Many thanks for your attention. This is an interesting question. What is the problem you are trying to solve and how do the boundary conditions function as part of this system? One of the functions that I need to minimized is: sum( ( ( hat_xi - xi )^2 )*uxi^-2 + ( ( ( a+b*hat_xi ) - yi)^2 )*uyi^-2) the context: I need to considerate errors in regressors: x[i] ~ N( x[i] ; ux[i]^2 ) u = 'uncertainty' is the same of std, but this 'u' is because the metrology terminology. And, I would like to restrict the x[i] variables in ~95% CI. My dirty code (test) follow below Thanks again. Cleber ### n <- 7 ### TODO: any number??? xi <- c(1:n) ; uxi <- round( abs( rnorm( n,0,1e-1)),6) yi <- round(xi + uxi + rnorm(n,0,.9),6) ; uyi <- round(abs(rnorm( n,0,1e-1)),6) naive <- lm( yi ~ xi ) # p: parameters p <- 2 plot( xi,yi ) abline( naive ) fobjetiva <- function( optPar=c(xi,a,b) , xi, uxi, yi, uyi ) { n <- length( xi ) hat_xi <- optPar[1:n] ; a <- optPar[n+1] ; b <- optPar[n+2] sum( ( (hat_xi - xi)^2 )*uxi^-2 + ( ( (a+b*hat_xi) - yi)^2 )*uyi^-2 ) } ## testing fobjetiva(c(xi, coef(naive)), xi,uxi,yi,uyi) ### box-constraints seCoef <- sqrt(diag(vcov( naive ))) Linf <- as.numeric(c( xi-2*uxi, coef(naive)-5000*seCoef )) Lsup <- as.numeric(c( xi+2*uxi, coef(naive)+5000*seCoef )) metodo <- 4 # 1,2,3,4 ou 5 all_iterOptim <- capture.output( reportOptim <- optim( par=c(xi,coef(naive)), fn=fobjetiva, xi=xi, uxi=uxi, yi=yi, uyi=uyi, method=c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN")[metodo], lower=Linf, upper=Lsup, hessian=TRUE, control=list( REPORT=1, maxit=1e4, trace=6 ) ) ) ### get all steps all_steps <- grep("^X", all_iterOptim ) all_steps <- all_iterOptim[ all_steps ] steps <- length(all_steps) steps matrix_steps <- matrix(0,nr=steps, nc=(n+p) ) for( i in 1:steps ) { matrix_steps[i,] <- as.numeric(unlist(strsplit(all_steps[i], " "))[3:(2+n+p)]) } windows(restore=T) ### view a animation of this otimization for( i in 1:steps ) { x <- matrix_steps[i,1:n] a <- matrix_steps[i,n+p-1] b <- matrix_steps[i,n+p] y <- a+b*x plot( xi, yi, pch=19, main=paste("Passo",i,"de",steps,sep=" "), cex=2 ) abline(a,b, col='blue', lwd=3) abline(naive, lwd=2, lty=2, col='red') points( x, y, col='red', pch=19, cex=2 ) segments(xi,yi,x,y, lwd=2) Sys.sleep(.11) ###file = paste("ISO_",(i+100),".png", sep="") ###savePlot(filename=file, type ="png", device=dev.cur() ) } ###comando = "convert -dispose previous -adjoin -delay 35 ISO_*.png -loop 0 ISO_animator.gif" ###shell(comando) ###unlink("ISO_*.png") ## view trajectory windows(restore=T) par( mfrow=c(4,2)) for( i in 1:7 ){ restri <- xi[i]+uxi[i]*c(-2,2) interv <- range(matrix_steps[,i], restri ) plot(1:steps, matrix_steps[,i], t='l', xlab="Passos", ylab="x1", ylim=interv, lwd=2, las=2 ) abline( h=restri, col='red', lwd=2) titulo=c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN")[metodo] title(titulo) } I ask because the asymptotic theory behind your formula for 's.e.' breaks down with parameters at boundaries. It assumes that you are minimizing the negative log(likelihood) AND the optimum is in the interior of the region AND the log(likelihood) is sufficiently close to being parabolic that a reasonable approximation for the distribution of the maximum likelihood estimates (MLEs) has a density adequately approximated by a second-order Taylor series expansion about the MLEs. In this case, transforming the parameters will not solve the problem. If the maximum is at a boundary and if you send the boundary to Inf with a transformation, then a second-order Taylor series expansion of the log(likelihood) about the MLEs will be locally flat in some direction(s), so the hessian can not be inverted. These days, the experts typically approach problems like this using Monte Carlo, often in the form of Markov Chain Monte Carlo (MCMC). One example of an analysis of this type of problem appears in section 2.4 of Pinheiro and Bates (2000) Mixed-Effects Models in S and S-Plus (Springer). Hope this helps. Spencer Graves Cleber Nogueira Borges wrote: Hello all useRs, I am using the OPTIM function with particular interest in the method L-BFGS-B, because it is a box-constraint method. I have interest in the errors estimates too. I make: s.e. <- sqrt( diag( solve( optim(...,method='L-BFGS-B', hessian=TRUE)$hessian ))) but in help say: "Note that this is the Hessian of the unconstrained problem even if the box constraints are active." My doubts is: How to obtain a authentic hessian for a box-constraint problem? How I should make a interpretation of this result (concern the hessian) ? Is possible make some transformation or so can I considerate this result a good approximation?? I am grateful for some help! References are welcome! :-D Cleber Borges _
Re: [R] Dynamically switching lattice device characteristics in Sweave under Makefile control
On 6/24/08, Douglas Bates <[EMAIL PROTECTED]> wrote: > I am indebted to Deepayan Sarkar for lattice graphics, Fritz Leisch > for Sweave and the authors of the beamer package for LaTeX. For me > these are a "killer app" combination. I wouldn't want to go back to > creating presentations in any other way. > > When I create a presentation I use a Makefile that allows me to the > presentation version of the slides, a 4-up version for printing on > letter paper and a 4-up A4 version. Sample files can be found at > http://www.stat.wisc.edu/~bates/IMPS2008 > > When creating the printable versions I want to invoke something like > > lattice.options(default.theme = standard.theme(color = FALSE)) > > in the "preliminaries" chunk so the 4-up slides can be printed on a > black-and-white printer without losing too much information. I > haven't worked out a way of passing this information in to the > individual sections yet. I would welcome suggestions. If you look in > the Makefile you will see that there is a fooD.tex and a fooH.tex file > controlling whether the display or the other one (I forget why I > called it H) is active. That is how I control the beamer stuff. The > problem for me is that the device characteristics need to be > controlled in the individual .Rnw files The only general solution would probably be at the level of R CMD Sweave; i.e., going back to the old days, have something like %.tex: %.Rnw echo "library(tools); library(lattice); lattice.options(default.theme = standard.theme(color = FALSE)); Sweave('$<') " | ${R_PROG} --vanilla --silent A less general solution (that I use myself) takes advantage of the fact that Sweave by default produces both eps and pdf versions. You can have separate lattice settings for two devices, and it so happens that the default for postscript is black and white while pdf is color. So, once you have all your Rnw files processed, texi2dvi --pdf foo.tex will produce a pdf with color figures, and texi2dvi foo.tex dvips foo.dvi ps2pdf foo.ps will produce a pdf with black and white figures. Since the last sequence is usually needed only for one special .tex file (the handout version), I have it hard-coded in the Makefile. -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error message: Bad value
On 24/06/2008 3:12 PM, Toby Gass wrote: Dear R help, In the middle of my session, I started receiving the error message "bad value" regardless of what I entered. I had to close R and restart it. When the error occurred, I was creating basic lattice plots, with no other add-on packages running. I am running R through John Fox's XEmacs interface, XEmacs version 21.4.20 on a Windows XP Pro machine with 2 GB of RAM. I have had no other problems. I've found 2 similar reports in the R-help archive, neither of which was resolved; one of the earlier posters was running Linux. That message is probably being printed in response to memory corruption. platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 6.2 That version is a little old; 2.7.1 was just released. If you can make the error reproducible in a current version (or even in 2.6.2), it would be very helpful to post the recipe, and it will probably get fixed. Duncan Murdoch year 2008 month 02 day 08 svn rev 44383 language R version.string R version 2.6.2 (2008-02-08) Previous reports are found here: http://tolstoy.newcastle.edu.au/R/e4/help/08/01/0686.html http://tolstoy.newcastle.edu.au/R/e2/help/07/06/19095.html I do not need a response, unless there is a preventative measure, but thought I would bring this to your attention. Thank you, Toby Toby Gass Graduate Degree Program in Ecology Department of Forest, Rangeland, and Watershed Stewardship Warner College of Natural Resources Colorado State University Fort Collins, CO 80523 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] running R-code outside of R
You can set up a web site and have them use that. Then they just need a browser. See www.rpad.org for one way or develop an internal or external site using any technology you know and call R on the back end. On Tue, Jun 24, 2008 at 2:01 PM, Roger Leenders <[EMAIL PROTECTED]> wrote: > > R 2.7.0, WinXP > > Hi list, > > I have written some code in R that I would like to share with others who > are not R-users. Is there a way to compile the code so it will run > outside of R? > The best thing would be a functionality to compile the code into a ".exe" > file that does not require the user to have R installed or to know how to > use R. The persons I would like to make the program available to are > unlikely to ever need or use software like R. > > Is there a functionality that will allow others to use my code without > needing R itself? > > thanks, roger > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] running R-code outside of R
Roger, Following on to Spencer's comments, we have had some success using RWui http://rwui.cryst.bbk.ac.uk/ to build web enabled versions of (non-interactive) R programs. Advantage is your users only need a browser. No exe to install. Downside is you need to have a web server accessible to your user base. We're using a very simple Tomcat setup within our firewall to provide access to canned R scripts. HTH, Jim Porzak Responsys, Inc. San Francisco, CA http://www.linkedin.com/in/jimporzak On Tue, Jun 24, 2008 at 11:01 AM, Roger Leenders <[EMAIL PROTECTED]> wrote: > > R 2.7.0, WinXP > > Hi list, > > I have written some code in R that I would like to share with others who > are not R-users. Is there a way to compile the code so it will run > outside of R? > The best thing would be a functionality to compile the code into a ".exe" > file that does not require the user to have R installed or to know how to > use R. The persons I would like to make the program available to are > unlikely to ever need or use software like R. > > Is there a functionality that will allow others to use my code without > needing R itself? > > thanks, roger > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] logistic regression
It looks like A*B*C*D is a complete, totally saturated model, (the residual deviance is effectively zero, and the residual degrees of freedom is exactly zero - this is a clue). So when you try to put even more parameters into the model and even higher way interactions, something has to give. I find 3-factor interactions are about as much as I can think about without getting a bit giddy. Do you really need 4- and 5-factor interactions? If so, your only option is to get more data. Bill Venables CSIRO Laboratories PO Box 120, Cleveland, 4163 AUSTRALIA Office Phone (email preferred): +61 7 3826 7251 Fax (if absolutely necessary): +61 7 3826 7304 Mobile: +61 4 8819 4402 Home Phone: +61 7 3286 7700 mailto:[EMAIL PROTECTED] http://www.cmis.csiro.au/bill.venables/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mikhail Spivakov Sent: Wednesday, 25 June 2008 9:31 AM To: r-help@r-project.org Subject: [R] logistic regression Hi everyone, I'm sorry if this turns out to be more a statistical question than one specifically about R - but would greatly appreciate your advice anyway. I've been using a logistic regression model to look at the relationship between a binary outcome (say, the odds of picking n white balls from a bag containing m balls in total) and a variety of other binary parameters: _ > a.fit <- glm (data=a, formula=cbind(WHITE,ALL-WHITE)~A*B*C*D, > family=binomial(link="logit")) > summary(a.fit) glm(formula = cbind(SUCCESS, ALL - SUCCESS) ~ A * B * C * D family = binomial(link = "logit"), data = a) Deviance Residuals: [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Coefficients: EstimateStd.Error z value Pr(>|z|) (Intercept) -0.697510.02697 -25.861 <2.00E-16 *** A -0.029110.05451 -0.534 0.593335 B 0.39842 0.06871 5.798 6.70E-09*** C 0.829 0.06745 12.29 <2.00E-16 *** D 0.05928 0.11133 0.532 0.594401 A:B -0.440530.13807 -3.191 0.001419** A:C -0.495960.13664 -3.63 0.000284*** B:C -0.621940.14164 -4.391 1.13E-05*** A:D -0.4031 0.2279 -1.769 0.076938. B:D -0.602380.25978 -2.319 0.020407* C:D -0.584670.27195 -2.15 0.031558* A:B:C 0.5006 0.27364 1.829 0.067335. A:B:D 0.51868 0.4683 1.108 0.268049 A:C:D 0.32882 0.51226 0.642 0.520943 B:C:D 0.56301 0.49903 1.128 0.259231 A:B:C:D -0.321150.87969 -0.365 0.715059 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: 2.2185e+02 on 15 degrees of freedom Residual deviance: 1.0385e-12 on 0 degrees of freedom AIC: 124.50 Number of Fisher Scoring iterations: 3 _ This seems to produce sensible results given the actual data. However, there are actually three types of balls in the experiment and I need to model the relationship between the odds of picking each of the type and the parameters A,B,C,D. So what I do now is split the initial data table and just run glm three times: >all [fictional data] TYPE WHITE ALL A B C D a 100 400 1 0 0 0 b 200 600 1 0 0 0 c 10 300 1 0 0 0 a 30 100 1 1 1 1 b 50 200 1 1 1 1 c 20 120 1 1 1 1 > a<-all[all$type=="a",] > b<-all[all$type=="b",] > c<-all[all$type=="c",] > a.fit <- glm (data=a, formula=cbind(WHITE,ALL-WHITE)~A*B*C*D, > family=binomial(link="logit")) > b.fit <- glm (data=b, formula=cbind(WHITE,ALL-WHITE)~A*B*C*D, > family=binomial(link="logit")) > c.fit <- glm (data=c, formula=cbind(WHITE,ALL-WHITE)~A*B*C*D, > family=binomial(link="logit")) But it seems to me that I should be able to incorporate TYPE into the model. Something like: >summary(glm(data=example2,family=binomial(link="logit"),formula=cbind(W HITE,ALL-WHITE)~TYPE*A*B*C*D)) [please see the output below] However, when I do this, it does not seem to give an expected result. Is this not the right way to do it? Or this is actually less powerful than running the three models separately? Will greatly appreciate your advice! Many thanks Mikhail - EstimateStd.Error z value Pr(>|z|) (Intercept) -8.90E-01 1.91E-02-46.553 <2.00E-16 *** TYPE1 1.93E-012.47E-027.822 5.18E-15*** TYPE2 1.19E+002.42E-0249.108 <2.00E-16 *** A 1.89E-013.34E-025.665 1.47E-08*** B 1.60E-014.41E-023.627 0.000286*
Re: [R] running R-code outside of R
A short answer to your question is 'yes and no': R is an interpreted language. There may have been attempts to create a "compiler" for R, but I don't know if any have actually succeeded very well. However, there are ways to (a) call R from other languages and (b) run R in batch mode. For example, I've seen packages that allow Excel users to run selected R functions. I'm not current on preferred ways of doing that, but if I had to do it, I might consider the RExcelInstaller and RODBC packages. Also, I know people have created web pages that pass data to R and display the results in a web page without burdening the user with learning R. I don't know how this works, but I just got 125 hits from "RSiteSearch('running R in batch mode')". If you want to provide more specifics of what you would like to do, you might get more useful suggestions. And, yes, I do believe in magic, but sometimes it requires a little creative thought. Hope this helps. Spencer Graves Rolf Turner wrote: On 25/06/2008, at 6:01 AM, Roger Leenders wrote: R 2.7.0, WinXP Hi list, I have written some code in R that I would like to share with others who are not R-users. Is there a way to compile the code so it will run outside of R? The best thing would be a functionality to compile the code into a ".exe" file that does not require the user to have R installed or to know how to use R. The persons I would like to make the program available to are unlikely to ever need or use software like R. Is there a functionality that will allow others to use my code without needing R itself? This reminds me of that old Lovin' Spoonful song: ``Do You Believe in Magic?'' cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Measuring Goodness of a Matrix
Thanks so much all. I will try out each of your suggestions. - Gundala Viswanath Jakarta - Indonesia On Wed, Jun 25, 2008 at 8:01 AM, Moshe Olshansky <[EMAIL PROTECTED]> wrote: > What do you mean by "A similar to X"? > Do you mean norm of the difference, similar eigenvalues/vectors, anything > else? > > > --- On Wed, 25/6/08, Gundala Viswanath <[EMAIL PROTECTED]> wrote: > >> From: Gundala Viswanath <[EMAIL PROTECTED]> >> Subject: [R] Measuring Goodness of a Matrix >> To: [EMAIL PROTECTED] >> Received: Wednesday, 25 June, 2008, 12:41 AM >> Hi all, >> >> Suppose I have 2 matrices A and B. >> And I want to measure how good each of this matrix is. >> >> So I intend to compare A and B with another "gold >> standard" >> matrix X. Meaning the more similar a matrix to X the better >> it is. >> >> What is the common way in R to >> measure matrix similarity (ie. A vs X, and B vs X) ? >> >> >> - Gundala Viswanath >> Jakarta - Indonesia >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, >> reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] logistic regression
Hi everyone, I'm sorry if this turns out to be more a statistical question than one specifically about R - but would greatly appreciate your advice anyway. I've been using a logistic regression model to look at the relationship between a binary outcome (say, the odds of picking n white balls from a bag containing m balls in total) and a variety of other binary parameters: _ > a.fit <- glm (data=a, formula=cbind(WHITE,ALL-WHITE)~A*B*C*D, > family=binomial(link="logit")) > summary(a.fit) glm(formula = cbind(SUCCESS, ALL - SUCCESS) ~ A * B * C * D family = binomial(link = "logit"), data = a) Deviance Residuals: [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Coefficients: EstimateStd.Error z value Pr(>|z|) (Intercept) -0.697510.02697 -25.861 <2.00E-16 *** A -0.029110.05451 -0.534 0.593335 B 0.39842 0.06871 5.798 6.70E-09*** C 0.829 0.06745 12.29 <2.00E-16 *** D 0.05928 0.11133 0.532 0.594401 A:B -0.440530.13807 -3.191 0.001419** A:C -0.495960.13664 -3.63 0.000284*** B:C -0.621940.14164 -4.391 1.13E-05*** A:D -0.4031 0.2279 -1.769 0.076938. B:D -0.602380.25978 -2.319 0.020407* C:D -0.584670.27195 -2.15 0.031558* A:B:C 0.5006 0.27364 1.829 0.067335. A:B:D 0.51868 0.4683 1.108 0.268049 A:C:D 0.32882 0.51226 0.642 0.520943 B:C:D 0.56301 0.49903 1.128 0.259231 A:B:C:D -0.321150.87969 -0.365 0.715059 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: 2.2185e+02 on 15 degrees of freedom Residual deviance: 1.0385e-12 on 0 degrees of freedom AIC: 124.50 Number of Fisher Scoring iterations: 3 _ This seems to produce sensible results given the actual data. However, there are actually three types of balls in the experiment and I need to model the relationship between the odds of picking each of the type and the parameters A,B,C,D. So what I do now is split the initial data table and just run glm three times: >all [fictional data] TYPE WHITE ALL A B C D a 100 400 1 0 0 0 b 200 600 1 0 0 0 c 10 300 1 0 0 0 a 30 100 1 1 1 1 b 50 200 1 1 1 1 c 20 120 1 1 1 1 > a<-all[all$type=="a",] > b<-all[all$type=="b",] > c<-all[all$type=="c",] > a.fit <- glm (data=a, formula=cbind(WHITE,ALL-WHITE)~A*B*C*D, > family=binomial(link="logit")) > b.fit <- glm (data=b, formula=cbind(WHITE,ALL-WHITE)~A*B*C*D, > family=binomial(link="logit")) > c.fit <- glm (data=c, formula=cbind(WHITE,ALL-WHITE)~A*B*C*D, > family=binomial(link="logit")) But it seems to me that I should be able to incorporate TYPE into the model. Something like: >summary(glm(data=example2,family=binomial(link="logit"),formula=cbind(WHITE,ALL-WHITE)~TYPE*A*B*C*D)) [please see the output below] However, when I do this, it does not seem to give an expected result. Is this not the right way to do it? Or this is actually less powerful than running the three models separately? Will greatly appreciate your advice! Many thanks Mikhail - EstimateStd.Error z value Pr(>|z|) (Intercept) -8.90E-01 1.91E-02-46.553 <2.00E-16 *** TYPE1 1.93E-012.47E-027.822 5.18E-15*** TYPE2 1.19E+002.42E-0249.108 <2.00E-16 *** A 1.89E-013.34E-025.665 1.47E-08*** B 1.60E-014.41E-023.627 0.000286*** C 2.24E-024.91E-020.455 0.64906 D 1.96E-016.58E-022.982 0.002868** TYPE1:A -2.19E-01 4.59E-02-4.759 1.95E-06*** TYPE2:A -9.08E-01 4.50E-02-20.178 <2.00E-16 *** TYPE1:C 2.39E-015.93E-024.022 5.77E-05*** TYPE2:B -1.82E+00 6.46E-02-28.178 <2.00E-16 *** A:B -2.26E-01 8.52E-02-2.649 0.008066** TYPE1:C 8.07E-016.27E-0212.87 <2.00E-16 *** TYPE2:C -2.51E+00 7.83E-02-32.039 <2.00E-16 *** A:C -1.70E-01 9.51E-02-1.783 0.074512. B:C -3.01E-01 1.12E-01-2.698 0.006985** TYPE1:D -1.37E-01 9.20E-02-1.489 0.136548 TYPE2:D -1.13E+00 9.19E-02-12.329 <2.00E-16 *** A:D -2.11E-01 1.27E-01-1.655 0.097953. B:D -2.15E-01 1.55E-01-1.387 0.165472 C:D -5.51E-01
Re: [R] Find max of a row in data frame (like Excel)
?pmax Anh Tran wrote: Hi, Here's the data we have: rs[1:5,] probe_id f1 f2 f3 f4 MA f 1 A_68_P20002076 2 58 0 0 1.51778114 6.344453 59 2 A_68_P20002775 22 8 15 0 0.43419304 5.488819 59 3 A_68_P20005791 43 3 0 0 0.05698666 9.830594 59 4 A_68_P20005805 11 34 0 0 1.71076835 6.624038 59 5 A_68_P20006729 16 44 0 0 0.85498261 6.044229 59 I want rs$f be the max of f1, f2, f3, f4 like a function in excel (=max(f1, f2, f3, f4)). How should we do it in R? I'm not familiar with programing with list. So please be patient Thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Equivalent of Mathematica's Apply
Thanks all! JP On Tue, Jun 24, 2008 at 3:30 PM, Franz Mueter <[EMAIL PROTECTED]> wrote: > Try > >> apply(ind, 1, function(i) x[i[1]:i[2]]) > > which returns a matrix if all sequences are the same length, a list > otherwise > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf Of Juan Pablo Romero Méndez > Sent: Tuesday, June 24, 2008 11:51 AM > To: [EMAIL PROTECTED] > Subject: [R] Equivalent of Mathematica's Apply > > Hello, > > Is there some equivalent function in R of Mathematica's "Apply" > > i.e. > > Apply[ f, g[a,b]] ==> f[a,b] > > > In concret, I have a matrix of indexes: > >> ind = cbind(1:5, 1:5+5) > >> ind > > [,1] [,2] > [1,]16 > [2,]27 > [3,]38 > [4,]49 > [5,]5 10 > > > and I'd like to extract sequences 1:6, 2:7, 3:8, ..., 5:10 from a vector x. > > What would be the most compact way of achieving this? > > I've tried > > sapply(1:5, function(i) x[ind[i,1] : ind[i,2]]) > > > Although > > sapply(1:5, function(i) x[seq(ind[i,])]) > > would be better (if it worked). > > Regards, > > Juan Pablo > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error message: Bad value
Dear R help, In the middle of my session, I started receiving the error message "bad value" regardless of what I entered. I had to close R and restart it. When the error occurred, I was creating basic lattice plots, with no other add-on packages running. I am running R through John Fox's XEmacs interface, XEmacs version 21.4.20 on a Windows XP Pro machine with 2 GB of RAM. I have had no other problems. I've found 2 similar reports in the R-help archive, neither of which was resolved; one of the earlier posters was running Linux. platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 6.2 year 2008 month 02 day 08 svn rev 44383 language R version.string R version 2.6.2 (2008-02-08) Previous reports are found here: http://tolstoy.newcastle.edu.au/R/e4/help/08/01/0686.html http://tolstoy.newcastle.edu.au/R/e2/help/07/06/19095.html I do not need a response, unless there is a preventative measure, but thought I would bring this to your attention. Thank you, Toby Toby Gass Graduate Degree Program in Ecology Department of Forest, Rangeland, and Watershed Stewardship Warner College of Natural Resources Colorado State University Fort Collins, CO 80523 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Find max of a row in data frame (like Excel)
Hi Anh, I know that it is not so elegant, but may work. x<-runif(10) y<-runif(10)*2 z<-runif(10)*3 df<-data.frame(cbind(x,y,z)) df df$f<-NULL for (i in 1:nrow(df)) { df[i,"f"]<-max(c(df[i,"x"],df[i,"y"],df[i,"z"])) } Of course, others that know better apply family will solve if with a line :-) There are some functions for rowSums, rowMeans (see the help). Kind regards, miltinho On 6/24/08, Anh Tran <[EMAIL PROTECTED]> wrote: > > Hi, > Here's the data we have: > > > rs[1:5,] >probe_id f1 f2 f3 f4 MA f > 1 A_68_P20002076 2 58 0 0 1.51778114 6.344453 59 > 2 A_68_P20002775 22 8 15 0 0.43419304 5.488819 59 > 3 A_68_P20005791 43 3 0 0 0.05698666 9.830594 59 > 4 A_68_P20005805 11 34 0 0 1.71076835 6.624038 59 > 5 A_68_P20006729 16 44 0 0 0.85498261 6.044229 59 > > I want rs$f be the max of f1, f2, f3, f4 like a function in excel (=max(f1, > f2, f3, f4)). > > How should we do it in R? I'm not familiar with programing with list. So > please be patient > Thanks > -- > Regards, > Anh Tran > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Measuring Goodness of a Matrix
What do you mean by "A similar to X"? Do you mean norm of the difference, similar eigenvalues/vectors, anything else? --- On Wed, 25/6/08, Gundala Viswanath <[EMAIL PROTECTED]> wrote: > From: Gundala Viswanath <[EMAIL PROTECTED]> > Subject: [R] Measuring Goodness of a Matrix > To: [EMAIL PROTECTED] > Received: Wednesday, 25 June, 2008, 12:41 AM > Hi all, > > Suppose I have 2 matrices A and B. > And I want to measure how good each of this matrix is. > > So I intend to compare A and B with another "gold > standard" > matrix X. Meaning the more similar a matrix to X the better > it is. > > What is the common way in R to > measure matrix similarity (ie. A vs X, and B vs X) ? > > > - Gundala Viswanath > Jakarta - Indonesia > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Find max of a row in data frame (like Excel)
Is this what you want: > x <- read.table(textConnection(" probe_id f1 f2 f3 f4 M > A f + 1 A_68_P20002076 2 58 0 0 1.51778114 6.344453 59 + 2 A_68_P20002775 22 8 15 0 0.43419304 5.488819 59 + 3 A_68_P20005791 43 3 0 0 0.05698666 9.830594 59 + 4 A_68_P20005805 11 34 0 0 1.71076835 6.624038 59 + 5 A_68_P20006729 16 44 0 0 0.85498261 6.044229 59"), header=TRUE) > closeAllConnections() > # 'apply' to the rows; need to convert to numeric since it is coersed to > character > x$f <- apply(x, 1, function(a) max(as.numeric(a[c('f1','f2','f3','f4')]))) > x probe_id f1 f2 f3 f4 MA f 1 A_68_P20002076 2 58 0 0 1.51778114 6.344453 58 2 A_68_P20002775 22 8 15 0 0.43419304 5.488819 22 3 A_68_P20005791 43 3 0 0 0.05698666 9.830594 43 4 A_68_P20005805 11 34 0 0 1.71076835 6.624038 34 5 A_68_P20006729 16 44 0 0 0.85498261 6.044229 44 > On Tue, Jun 24, 2008 at 6:41 PM, Anh Tran <[EMAIL PROTECTED]> wrote: > Hi, > Here's the data we have: > >> rs[1:5,] >probe_id f1 f2 f3 f4 MA f > 1 A_68_P20002076 2 58 0 0 1.51778114 6.344453 59 > 2 A_68_P20002775 22 8 15 0 0.43419304 5.488819 59 > 3 A_68_P20005791 43 3 0 0 0.05698666 9.830594 59 > 4 A_68_P20005805 11 34 0 0 1.71076835 6.624038 59 > 5 A_68_P20006729 16 44 0 0 0.85498261 6.044229 59 > > I want rs$f be the max of f1, f2, f3, f4 like a function in excel (=max(f1, > f2, f3, f4)). > > How should we do it in R? I'm not familiar with programing with list. So > please be patient > Thanks > -- > Regards, > Anh Tran > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to make auto.key to produce a legend that uses line pattern (rather than data point) as labels?
Hi! I am working on a line graph under xyplot. what command should I feed to auto.key so that it uses the line pattern of series as labels? Also where can I find doc about all options that I can feed to auto.key? Thanks! Mark __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Find max of a row in data frame (like Excel)
Hi, Here's the data we have: > rs[1:5,] probe_id f1 f2 f3 f4 MA f 1 A_68_P20002076 2 58 0 0 1.51778114 6.344453 59 2 A_68_P20002775 22 8 15 0 0.43419304 5.488819 59 3 A_68_P20005791 43 3 0 0 0.05698666 9.830594 59 4 A_68_P20005805 11 34 0 0 1.71076835 6.624038 59 5 A_68_P20006729 16 44 0 0 0.85498261 6.044229 59 I want rs$f be the max of f1, f2, f3, f4 like a function in excel (=max(f1, f2, f3, f4)). How should we do it in R? I'm not familiar with programing with list. So please be patient Thanks -- Regards, Anh Tran [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] spineplot (graphics package): how to control font size?
On 24/06/2008 5:21 PM, Paul Shannon wrote: I cannot modify the font size of the standard text items for the splineplot function found in the standard graphics package. Here is a tiny example, in which I try (but fail) to make the main title large. tbl = read.table ('http://www.ggobi.org/book/data/tips.csv', sep=',', header=T) spineplot (table (tbl$DAY, tbl$SEX), main='TIPS', cex.main=3) None of the other 'cex' parameters seem to work either, but cex.main is probably a sufficient example. None of the cex parameters is listed as a parameter on ?spineplot, so presumably they just aren't there. You will have to plot with blank titles, and use title(main='TIPS', cex.main=3) in a following call. Duncan Murdoch Any tips for me? Thanks! - Paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Dynamically switching lattice device characteristics in Sweave under Makefile control
I am indebted to Deepayan Sarkar for lattice graphics, Fritz Leisch for Sweave and the authors of the beamer package for LaTeX. For me these are a "killer app" combination. I wouldn't want to go back to creating presentations in any other way. When I create a presentation I use a Makefile that allows me to the presentation version of the slides, a 4-up version for printing on letter paper and a 4-up A4 version. Sample files can be found at http://www.stat.wisc.edu/~bates/IMPS2008 When creating the printable versions I want to invoke something like lattice.options(default.theme = standard.theme(color = FALSE)) in the "preliminaries" chunk so the 4-up slides can be printed on a black-and-white printer without losing too much information. I haven't worked out a way of passing this information in to the individual sections yet. I would welcome suggestions. If you look in the Makefile you will see that there is a fooD.tex and a fooH.tex file controlling whether the display or the other one (I forget why I called it H) is active. That is how I control the beamer stuff. The problem for me is that the device characteristics need to be controlled in the individual .Rnw files Should you be inclined to read the content of the slides (and do bear in mind that they are a work in progress, to be presented on Sunday) I will tell you I am particularly proud of the slide entitled "Definition of linear mixed-effects models" (about slide 13 - depending on how you count). In one slide that describes a very general form of the model. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] GWA plot
I need some help with a genome-wide association scatterplot. A recently published example of such a plot is attached to this message. Typical variables include: Y: -logP-value (range from 0 to 8) X: chromosomal distance Z: chromosomes 1 through 22 and X (a factor with 23 levels) I used coplot(Y~X|CHR) and xyplot(Y~X|CHR), but I am not sure how to get the entire graph in a single panel (see attached). Please let me know if there is any simple way to produce such a plot using the existing R graphing commands. Thanks! Chris __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] spineplot (graphics package): how to control font size?
I cannot modify the font size of the standard text items for the splineplot function found in the standard graphics package. Here is a tiny example, in which I try (but fail) to make the main title large. tbl = read.table ('http://www.ggobi.org/book/data/tips.csv', sep=',', header=T) spineplot (table (tbl$DAY, tbl$SEX), main='TIPS', cex.main=3) None of the other 'cex' parameters seem to work either, but cex.main is probably a sufficient example. Any tips for me? Thanks! - Paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Measuring Goodness of a Matrix
Hi Gundala, >> Suppose I have 2 matrices A and B. >> And I want to measure how good each of this matrix is. You really want to be using Robert & Escoufier's RV-coefficient (A unifying tool for linear multivariate statistical methods: The $RV$-coefficient Appl. Statist., 1976, 25, 257-265). Several packages in R use it. If I were you I would look at the coinertia() function in package ade4, which is a fine implementation, with a good plot method. There is also a randomization test. You could also look at Procrustean analysis (also with a randomization test and also implemented in the named package). HTH, Mark. Gundala Viswanath wrote: > > Hi all, > > Suppose I have 2 matrices A and B. > And I want to measure how good each of this matrix is. > > So I intend to compare A and B with another "gold standard" > matrix X. Meaning the more similar a matrix to X the better it is. > > What is the common way in R to > measure matrix similarity (ie. A vs X, and B vs X) ? > > > - Gundala Viswanath > Jakarta - Indonesia > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- View this message in context: http://www.nabble.com/Measuring-Goodness-of-a-Matrix-tp18092757p18100047.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Coloring Stripchart Points, or Better, Lattice Equivalent
On 6/24/08, Bryan Hanson <[EMAIL PROTECTED]> wrote: > If anyone remains interested, the solution in base graphics is to modify > stripchart.default, the last couple of lines where the coloring of points > defaults in a way that depends on groups. In my example, the groups are > being handled collectively with the coloring. Code is below. > > Deepayan has noted that stacking of this type is not possible in Lattice > graphics, and would have to be coded directly (probably not too much of a > modification of what I give here, but I'm a novice!). Here's a lattice version (well, mainly it's a function to calculate the y-coordinates; not very efficient, but should suffice for small datasets): ## utility to compute y-coordinates retaining order jitter.stack <- function(x, y = NULL, increment = 1) { if (!is.null(y)) { yold <- y for (yval in unique(yold)) { i <- yold == yval y[i] <- y[i] + jitter.stack(x[i], increment = increment) } y } else { y <- rep(0, length(x)) for (xval in unique(x)) { i <- x == xval y[i] <- increment * (seq_len(sum(i)) - 1) } y } } set.seed(13331) samples <- 100 # must be even index <- round(runif(samples, 1, 100)) # set up data resp <- rbinom(samples, 1, 0.5) yr <- rep(c("2005", "2006"), samples/2) all <- data.frame(index, resp, yr) all$sym <- ifelse(all$resp == 1, 1, 3) all$col <- ifelse(all$yr == 2005, "red", "blue") with(all, stripplot(interaction(yr, resp, sep = "/") ~ index, col = col, pch = sym, panel = function(x, y, ...) { ynew <- jitter.stack(x, as.numeric(y), increment = 0.05) panel.xyplot(x, ynew, ...) })) with(all, stripplot(~ index, col = col, pch = sym, ylim = c(0, 5), panel = function(x, y, ...) { ynew <- jitter.stack(x, as.numeric(y)) panel.xyplot(x, ynew, ...) })) -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] heatmap and continuous variable
Dear All, I want to plot a heat map with annotated columns. Both functions heatmap (stats) and heatmap.2 (gplots) can plot a horizontal side bar that can be used to visualize a categorical variable. In addition to a categorical variable, I would like to visualize a continuous variable. This could be done by small bars, a curve or simply numbers above the columns. (The Sample names are already located at the bottom.) Does someone have example code for this or a similar problem? Is this so special that I have to get down to the lattice package? Thank you, Hans-Ulrich -- Hans-Ulrich Klein Department of Medical Informatics and Biomathematics Westfälische Wilhelms-Universität Münster Tel.: +49 (0)251 83-58405 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] running R-code outside of R
On 25/06/2008, at 6:01 AM, Roger Leenders wrote: R 2.7.0, WinXP Hi list, I have written some code in R that I would like to share with others who are not R-users. Is there a way to compile the code so it will run outside of R? The best thing would be a functionality to compile the code into a ".exe" file that does not require the user to have R installed or to know how to use R. The persons I would like to make the program available to are unlikely to ever need or use software like R. Is there a functionality that will allow others to use my code without needing R itself? This reminds me of that old Lovin' Spoonful song: ``Do You Believe in Magic?'' cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Equivalent of Mathematica's Apply
Try > apply(ind, 1, function(i) x[i[1]:i[2]]) which returns a matrix if all sequences are the same length, a list otherwise -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Juan Pablo Romero Méndez Sent: Tuesday, June 24, 2008 11:51 AM To: [EMAIL PROTECTED] Subject: [R] Equivalent of Mathematica's Apply Hello, Is there some equivalent function in R of Mathematica's "Apply" i.e. Apply[ f, g[a,b]] ==> f[a,b] In concret, I have a matrix of indexes: > ind = cbind(1:5, 1:5+5) > ind [,1] [,2] [1,]16 [2,]27 [3,]38 [4,]49 [5,]5 10 and I'd like to extract sequences 1:6, 2:7, 3:8, ..., 5:10 from a vector x. What would be the most compact way of achieving this? I've tried sapply(1:5, function(i) x[ind[i,1] : ind[i,2]]) Although sapply(1:5, function(i) x[seq(ind[i,])]) would be better (if it worked). Regards, Juan Pablo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R help on for loop
Hi Ramya. Like this? for ( i in 1:nrow(map) ) { cat ("this is the line", i, "\n") } Miltinho. Brazil On 6/24/08, Rajasekaramya <[EMAIL PROTECTED]> wrote: > > > hi, > > I have a data stored in table format. The data is stored in the name map. > > 500545 rows and 3 columns. > > I want to use a for loop to scan through till the end of the row. > can i use like this. > > for ( i in 1:row(map) > { > } > > Kindly clarify me > > Cheers > Ramya > -- > View this message in context: > http://www.nabble.com/R-help-on-for-loop-tp18098661p18098661.html > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R help on for loop
hi, I have a data stored in table format. The data is stored in the name map. 500545 rows and 3 columns. I want to use a for loop to scan through till the end of the row. can i use like this. for ( i in 1:row(map) { } Kindly clarify me Cheers Ramya -- View this message in context: http://www.nabble.com/R-help-on-for-loop-tp18098661p18098661.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] persp plot
Thanks for your reply. When I did what you said z <- t(matrix(zdata, nrow = length(ydata))) persp(xdata, ydata, z) I got the following errors: Error in persp.default(xdata, ydata, z) : invalid 'x' argument Calls: persp -> persp.default In addition: Warning messages: 1: In min(x, na.rm = na.rm) : no non-missing arguments to min; returning Inf 2: In max(x, na.rm = na.rm) : no non-missing arguments to max; returning -Inf 3: In min(x, na.rm = na.rm) : no non-missing arguments to min; returning Inf 4: In max(x, na.rm = na.rm) : no non-missing arguments to max; returning -Inf Execution halted On Jun 24, 2008, at 2:07 PM, Franz Mueter wrote: Chad - I think what you want (after reading in your data) is: z <- t(matrix(zdata, nrow = length(ydata))) persp(xdata, ydata, z) Cheers, Franz -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] ] On Behalf Of Chad Junkermeier Sent: Tuesday, June 24, 2008 7:39 AM To: r-help@r-project.org Subject: [R] persp plot I have a set of data in the form x1, y1, z1 x1, y2, z2 ... x1, yN, zN x2, y1, z(N+1) x2, y2, z(N+2) ... x2, yN, z(2N) ...and so on... xM, yN, val(M*N) I have been trying to figure out how to get R to use this data in a persp plot. So far the only thing that I can figure out to do is to break the data file into three different files. The first file contains the x-coordinate data: x1 x2 ... xM The second file contains the data y1 y2 ... yN And finally the last file contains the data for the z-axis. z1 z2 ... z(M*N) Once I have the three data files created I use them in the following R script: cat << EOF | R --no-save def.par <- par(no.readonly = TRUE) en_range <- c(-6.2, 0.0) om_range <- c(-200.0, 500.0) ze_range <- c(0.0, 1.0) z_perspective <-c(0,3) xdata <- scan("x.txt", list(0)) ydata <- scan("y.txt", list(0)) zdata <- scan("z.txt", list(0)) f <- function(xdata,ydata) { rr <- zdata; rr } z <- outer(xdata, ydata, f) pdf(file="persp.pdf",height = 8, width =8) persp(xdata, ydata, z, axes = TRUE, nticks = 5, ticktype = "detailed",r=1.5) dev.off() q() EOF The problem is that when I look at the plot, the peaks of the zdata are i The problem is that when I look at the plot, the peaks of the zdata are in the wrong places on the x axis. I have carefully looked over my data files and I am confident that they are correct. Thus I believe that the error is in my R script; most likely in the following lines f <- function(xdata,ydata) { rr <- zdata; rr } z <- outer(xdata, ydata, f) Do you have any suggestions? Chad Junkermeier, Graduate Student Dept. of Physics West Virginia University PO Box 6315 210 Hodges Hall Morgantown WV 26506-6315 - Concurrently at: Dept. of Physics and Astronomy Brigham Young University Provo UT 84602 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Need ideas on how to show spikes in my data and how to code it in R
On 24/06/2008, at 8:10 AM, Daniel Folkinshteyn wrote: on 06/23/2008 03:40 PM Thomas Frööjd said the following: 2. Scale the data so they can be plotted on the same axis. The reference dataset has around 20 000 observations and my data from the clinic only around 3000 so I have to fix this otherwise the plot of the reference datset will be much bigger in the graph. if you do a density plot (see ?density in R), it will automatically be scaled. if you want the histogram scaled too, then after calculating the histogram frequencies, multiply them by a ratio of numberofobs for your data, and number of obs for reference data (i.e.: NOBS_yourdata / NOSB_refdata) I don't understand this. Why not just get hist() to plot on the density scale, thereby making its output commensurate with the output of density()? The hist() function will plot on the density scale if you ask it to. Set freq=FALSE (or prob=TRUE) in the call to hist. cheers, Rolf Turner ## Attention: This e-mail message is privileged and confidential. If you are not the intended recipient please delete the message and notify the sender. Any views or opinions presented are solely those of the author. This e-mail has been scanned and cleared by MailMarshal www.marshalsoftware.com ## __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Equivalent of Mathematica's Apply
Hello, Is there some equivalent function in R of Mathematica's "Apply" i.e. Apply[ f, g[a,b]] ==> f[a,b] In concret, I have a matrix of indexes: > ind = cbind(1:5, 1:5+5) > ind [,1] [,2] [1,]16 [2,]27 [3,]38 [4,]49 [5,]5 10 and I'd like to extract sequences 1:6, 2:7, 3:8, ..., 5:10 from a vector x. What would be the most compact way of achieving this? I've tried sapply(1:5, function(i) x[ind[i,1] : ind[i,2]]) Although sapply(1:5, function(i) x[seq(ind[i,])]) would be better (if it worked). Regards, Juan Pablo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error Handling
?try On Tue, Jun 24, 2008 at 1:59 PM, Sit Yee Kong <[EMAIL PROTECTED]> wrote: > > Hi All, > > The for-loop below stopped when error("Cannot get confidence intervals on > var-cov components: Non-positive definite approximate variance-covariance") > occurred. > I assigned a row of NA values > to the data frame "m1" manually and reset "j" in the for-loop every time > error returned. I'm wondering if > there is a function that can detect error or failure, so the for-loop WILL > NOT stop and the NA values can be assigned automatically if specified > condition met. This can solve my problem that I need to set the NA values > manually and reset j in for-loop every time error returned. Doing this > manually would be very tedious. > m1<-matrix(ncol=3,nrow=0) > for (j in 1:1000){ > > fit<-lme(Expression~1,random=~1|MonkeyID, > data=mydata1,subset=Probes==as.character(Probes_Blood_sub[j,"probe"])) > ci<-intervals(fit)$reStruct$MonkeyID^2 > m1<-rbind(m1,ci)} > Thanks,Sityee > > _ > The i'm Talkathon starts 6/24/08. For now, give amongst yourselves. > >[[alternative HTML version deleted]] > > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to solve empty cells in the contingency table?
Hi,Dear all R experts, I am trying to do the 2-way contingency table analysis by fitting the loglinear models. However, I found my table has several empty cells which are theoretically missing values.I have no idea of how to solve them coz we cannot compute the simulated p-value with zero marginals.Does someone have some suggestions? Please help me out, thanks a lot! Cheers, Yan _ ÐÂÄê»»ÐÂÑÕ£¬¿ìÀ´×±°ç×Ô¼ºµÄMSN¸øÐÄÒǵÄTAÒ»¸ö¾ªÏ²£¡ http://im.live.cn/emoticons/?ID=18 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] running R-code outside of R
R 2.7.0, WinXP Hi list, I have written some code in R that I would like to share with others who are not R-users. Is there a way to compile the code so it will run outside of R? The best thing would be a functionality to compile the code into a ".exe" file that does not require the user to have R installed or to know how to use R. The persons I would like to make the program available to are unlikely to ever need or use software like R. Is there a functionality that will allow others to use my code without needing R itself? thanks, roger __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error Handling
Hi All, The for-loop below stopped when error("Cannot get confidence intervals on var-cov components: Non-positive definite approximate variance-covariance") occurred. I assigned a row of NA values to the data frame "m1" manually and reset "j" in the for-loop every time error returned. Im wondering if there is a function that can detect error or failure, so the for-loop WILL NOT stop and the NA values can be assigned automatically if specified condition met. This can solve my problem that I need to set the NA values manually and reset j in for-loop every time error returned. Doing this manually would be very tedious. m1<-matrix(ncol=3,nrow=0) for (j in 1:1000){ fit<-lme(Expression~1,random=~1|MonkeyID, data=mydata1,subset=Probes==as.character(Probes_Blood_sub[j,"probe"])) ci<-intervals(fit)$reStruct$MonkeyID^2 m1<-rbind(m1,ci)} Thanks,Sityee _ The im Talkathon starts 6/24/08. For now, give amongst yourselves. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R help
?subset may help. --- On Tue, 6/24/08, Rajasekaramya <[EMAIL PROTECTED]> wrote: > From: Rajasekaramya <[EMAIL PROTECTED]> > Subject: [R] R help > To: r-help@r-project.org > Received: Tuesday, June 24, 2008, 12:27 AM > Hi there, > > I am very new to R.I have to write the code for the > following scenario > > Snp_Id Gene name score > 1 a > 2 b > 3 a > 4b > are the three columns in my table.There are many snp,s for > a particular > gene.I have to group all the snp to its corresponding > genname. > > my output should be > > genename a should have both the gene id 1 and 3. > genename b should have gene id 2 and 4 > > Kindly help me. > Ramya Thulasingam > > > > > -- > View this message in context: > http://www.nabble.com/R-help-tp18083552p18083552.html > Sent from the R help mailing list archive at Nabble.com. > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. __ [[elided Yahoo spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bar charts with error bars
Does this example help? my.values <- c(10, 5) err1 <- c(.5,.3) x <- barplot(my.values, ylim=c(0,12)) arrows(x,my.values-.5 ,x,my.values+.5, code=3, angle=90, length=.1) box() --- On Tue, 6/24/08, Liat RT <[EMAIL PROTECTED]> wrote: > From: Liat RT <[EMAIL PROTECTED]> > Subject: [R] Bar charts with error bars > To: r-help@r-project.org > Received: Tuesday, June 24, 2008, 11:06 AM > I would like to add error bars to a bar chart, I have > created in R. I am able to add error bars to a bar plot, > but the same method does not seem to work for my bar chart > version. > > Is there a way to add error bars to bar charts? > > > > > Audi, Fiat, Peugeot, Skoda, Porsche, Toyota, Ford - Kelkoo > har brugte biler til en hver smag! Klik her for at > sammenligne priser.(http://dk.yahoo.com/r/pat/mmb) > [[alternative HTML version > deleted]]__ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. __ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now at http://ca.toolbar.yahoo.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] spectral filtering
I would like to filter using a periodogram produced by spec.pgram() then pick the frequencies that I would like to filter out and then get the inverse back into the time domain. Any thoughts. Stephen -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fitdistr of a 3 parameter Gamma distribution
Serguei, You might want to look at the TransformedGamma or InverseTransformedGamma distributions, which are part of the actuar package, see page 41, 25 here: http://cran.r-project.org/web/packages/actuar/actuar.pdf You can then use fitdistr of the MASS package to fit the parameters. Regards, Markus Markus Gesmann │Associate Director│Libero Ventures Ltd, One Broadgate, London EC2M 2QS tel: +44 (0)207 826 9080│ dir: +44 (0)207 826 9085│fax: +44 (0)207 826 9090 │www.libero.uk.com A Lehman Brothers Company AUTHORISED AND REGULATED BY THE FINANCIAL SERVICES AUTHORITY -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Serguei Kaniovski Sent: 24 June 2008 16:52 To: [EMAIL PROTECTED] Subject: [R] Fitdistr of a 3 parameter Gamma distribution Hello, how can I fit a three, as opposed to a two parameter Gamma distribution, i.e. one in which "shape" and "rate" are not tied. Thanks, Serguei __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This message is intended for the personal and confidential use for the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction or as an official statement of Libero Ventures Ltd. Email transmissions cannot be guaranteed to be secure or error-free. Therefore we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Elliott's efficient unit root test
Dear Keli, To be a member of the R mailing list, just go to https://stat.ethz.ch/mailman/listinfo/r-help HTH, Jorge 2008/6/24 Xu, Ke-Li <[EMAIL PROTECTED]>: > Dear Gustaf and Stephen, > > > > The lines work - Thank you very much. "@teststat" is exactly what I want. > > > > I think the forums are very helpful. Could you kindly let me know how to be > a member since my message was held because of "Post by non-member to a > members-only list". > > > > Thanks again. > > > > Keli > > > > From: stephen sefick [mailto:[EMAIL PROTECTED] > Sent: 2008$BG/(B6$B7n(B24$BF|(B 4:54 > To: Gustaf Rydevik > Cc: Xu, Ke-Li; [EMAIL PROTECTED] > Subject: Re: [R] R help > > > > A comment from the peanut gallery- It is always good to write an > explicative title because it facilitates searching in the forums. > thanks > > Stephen > > On Tue, Jun 24, 2008 at 6:49 AM, Gustaf Rydevik <[EMAIL PROTECTED]> > wrote: > > dear Xu, > > does: > >library(urca) > >example(ur.ers) > >ers.gnp > >str(ers.gnp) > >[EMAIL PROTECTED] > > ,do what you want? > (this reminds me that I have to learn S4 sometime) > best, > > Gustaf Rydevik > > > > On Tue, Jun 24, 2008 at 3:52 AM, Xu, Ke-Li <[EMAIL PROTECTED]> wrote: > > Dear Sir/Madam, > > > > I found your email address and your correspondence with R-users. I hope > > you could help me with this question about the function "ur.ers" in the > > package of "urca". It is an improved unit root test (Elliott et al. 1996 > > Econometrica). Do you know how to extract the value of the test > > statistic from the output? The only thing I can get is the print-out of > > all results including the test statistic. But I am wondering whether the > > value is saved somewhere, like g$coef will give you the estimated > > coefficient, where g is a linear model lm object. > > > > Thank you very much. > > > > > > Best regards, > > Keli Xu > > > > > >[[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > > > -- > Gustaf Rydevik, M.Sci. > tel: +46(0)703 051 451 > address:Essingetorget 40,112 66 Stockholm, SE > skype:gustaf_rydevik > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > > > > -- > Let's not spend our time and resources thinking about things that are so > little or so large that all they really do for us is puff us up and make us > feel like gods. We are mammals, and have not exhausted the annoying little > problems of being mammals. > > -K. Mullis > > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Elliott's efficient unit root test
Dear Gustaf and Stephen, The lines work - Thank you very much. $B!H([EMAIL PROTECTED](J is exactly what I want. I think the forums are very helpful. Could you kindly let me know how to be a member since my message was held because of $B!H(JPost by non-member to a members-only list$B!I(J. Thanks again. Keli From: stephen sefick [mailto:[EMAIL PROTECTED] Sent: 2008$BG/(J6$B7n(J24$BF|(J 4:54 To: Gustaf Rydevik Cc: Xu, Ke-Li; [EMAIL PROTECTED] Subject: Re: [R] R help A comment from the peanut gallery- It is always good to write an explicative title because it facilitates searching in the forums. thanks Stephen On Tue, Jun 24, 2008 at 6:49 AM, Gustaf Rydevik <[EMAIL PROTECTED]> wrote: dear Xu, does: >library(urca) >example(ur.ers) >ers.gnp >str(ers.gnp) >[EMAIL PROTECTED] ,do what you want? (this reminds me that I have to learn S4 sometime) best, Gustaf Rydevik On Tue, Jun 24, 2008 at 3:52 AM, Xu, Ke-Li <[EMAIL PROTECTED]> wrote: > Dear Sir/Madam, > > I found your email address and your correspondence with R-users. I hope > you could help me with this question about the function "ur.ers" in the > package of "urca". It is an improved unit root test (Elliott et al. 1996 > Econometrica). Do you know how to extract the value of the test > statistic from the output? The only thing I can get is the print-out of > all results including the test statistic. But I am wondering whether the > value is saved somewhere, like g$coef will give you the estimated > coefficient, where g is a linear model lm object. > > Thank you very much. > > Best regards, > Keli Xu > > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Fitdistr of a 3 parameter Gamma distribution
Hello, how can I fit a three, as opposed to a two parameter Gamma distribution, i.e. one in which "shape" and "rate" are not tied. Thanks, Serguei __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] transform a table into a matrix
> "JohnF" == John Fox <[EMAIL PROTECTED]> > on Tue, 24 Jun 2008 08:10:43 -0400 writes: JohnF> Dear Maria, On 23-Jun-08, at 11:40 PM, Maria JohnF> Gavilanez wrote: >> Hi. >> >> is there a way to transform a table that has numeric and >> categorical variables into a matrix? JohnF> No, because all of the elements of a matrix must be JohnF> of the same mode, but a dataframe is a data structure JohnF> that can have heterogeneous columns. It's unclear JohnF> from your question where the "table" is located -- in JohnF> a file perhaps? If so, you can use read.table() to JohnF> read the data into a dataframe. Yes, and then possibly use data.matrix(.) to produce a numeric matrix where the "categorical variables" have become numeric (via their internal codes). Martin Maechler, ETH Zurich JohnF> I hope this helps, John JohnF> John JohnF> Fox, Professor Department of Sociology McMaster JohnF> University Hamilton ON Canada L8S 4M4 web: JohnF> socserv.mcmaster.ca/jfox >> >> >> thanks >> >> >> Maria Mercedes Gavilanez Department of Biological >> Sciences 107 Life Sciences Building Louisiana State >> University Baton Rouge, LA 70803 (225)578-4284 >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do >> read the posting guide >> http://www.R-project.org/posting-guide.html and provide >> commented, minimal, self-contained, reproducible code. JohnF> __ JohnF> R-help@r-project.org mailing list JohnF> https://stat.ethz.ch/mailman/listinfo/r-help PLEASE JohnF> do read the posting guide JohnF> http://www.R-project.org/posting-guide.html and JohnF> provide commented, minimal, self-contained, JohnF> reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reset row numbers when extracting a subset of a table
I assume that by table you mean data frame. Using the built in data frame, BOD, try this: > ix <- 2:4 > BOD[ix, ] Time demand 22 10.3 33 19.0 44 16.0 > data.frame(BOD[ix, ], row.names = seq_along(ix)) Time demand 12 10.3 23 19.0 34 16.0 On Tue, Jun 24, 2008 at 11:23 AM, <[EMAIL PROTECTED]> wrote: > Hi > > I created a new table by extracting only certain rows of table, but the row > numbers in my new table correspond to those from the original table. Is there > a > way to reset the row numbers in my new table so that they start from one? like > below: > > my table: >COL1 COL2 > 17 v 45 > 18 b 14 > 25 x 98 > > desired: > COL1 COL2 > 1 v 45 > 2 b 14 > 3 x 98 > > Thank you! > -Nina > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] changing scale range after an axis break
Megan J Bellamy gov.ns.ca> writes: > > Hello, > > I am constructing a boxplot but have a very wide range of values (zero - ~28000). I have placed an axis break at > the 8000 mark but would like to have a different scale above the break that ranges from 8000-28000. ... See gap.plot and axis.break (in the examples for axis.break, in the plotrix package) Ben Bolker __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] persp plot
I have a set of data in the form x1, y1, z1 x1, y2, z2 ... x1, yN, zN x2, y1, z(N+1) x2, y2, z(N+2) ... x2, yN, z(2N) ...and so on... xM, yN, val(M*N) I have been trying to figure out how to get R to use this data in a persp plot. So far the only thing that I can figure out to do is to break the data file into three different files. The first file contains the x-coordinate data: x1 x2 ... xM The second file contains the data y1 y2 ... yN And finally the last file contains the data for the z-axis. z1 z2 ... z(M*N) Once I have the three data files created I use them in the following R script: cat << EOF | R --no-save def.par <- par(no.readonly = TRUE) en_range <- c(-6.2, 0.0) om_range <- c(-200.0, 500.0) ze_range <- c(0.0, 1.0) z_perspective <-c(0,3) xdata <- scan("x.txt", list(0)) ydata <- scan("y.txt", list(0)) zdata <- scan("z.txt", list(0)) f <- function(xdata,ydata) { rr <- zdata; rr } z <- outer(xdata, ydata, f) pdf(file="persp.pdf",height = 8, width =8) persp(xdata, ydata, z, axes = TRUE, nticks = 5, ticktype = "detailed",r=1.5) dev.off() q() EOF The problem is that when I look at the plot, the peaks of the zdata are i The problem is that when I look at the plot, the peaks of the zdata are in the wrong places on the x axis. I have carefully looked over my data files and I am confident that they are correct. Thus I believe that the error is in my R script; most likely in the following lines f <- function(xdata,ydata) { rr <- zdata; rr } z <- outer(xdata, ydata, f) Do you have any suggestions? Chad Junkermeier, Graduate Student Dept. of Physics West Virginia University PO Box 6315 210 Hodges Hall Morgantown WV 26506-6315 - Concurrently at: Dept. of Physics and Astronomy Brigham Young University Provo UT 84602 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reset row numbers when extracting a subset of a table
Nina, these are not row NUMBERS, but row NAMES. Numbers are actually reset, they always start with 1 and they are continuous. Just try doing T[1,] on your table. If you want to reset row names, you can do this: rownames(T) <- seq(length=nrow(T)) or you can even remove them: rownames(T) <- NULL Best, Gabor On Tue, Jun 24, 2008 at 11:23:56AM -0400, [EMAIL PROTECTED] wrote: > Hi > > I created a new table by extracting only certain rows of table, but the row > numbers in my new table correspond to those from the original table. Is there > a > way to reset the row numbers in my new table so that they start from one? like > below: > > my table: > COL1 COL2 > 17 v 45 > 18 b 14 > 25 x 98 > > desired: >COL1 COL2 > 1 v 45 > 2 b 14 > 3 x 98 > > Thank you! > -Nina > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Csardi Gabor <[EMAIL PROTECTED]>UNIL DGM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ylab position in levelplot
is it possible to change the position of the ylab in a lavelplot from the default (left) to the right? thanks sw __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem when building a test R package on PC
I don't know the problem per se, but I can say this. In the past, I used the Rossi example and wasn't able to build an R package for Windows. I also explored other resources on the web and came to a similar halt. The only solution for me was to read the R manual and follow the Murdoch instructions on his web site (link below). I think staying with the canonical guides for this is the only way to get a build done properly. http://www.murdoch-sutherland.com/Rtools/ > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Xiaohui Wang > Sent: Tuesday, June 24, 2008 11:22 AM > To: r-help@r-project.org > Subject: [R] Problem when building a test R package on PC > > > I followed the instruction of building R package on PC by > Peter Rossi. I got problem when I tried to build a R package > from his example, test.zip. The problem occurs when I tried to > > R CMD check test > > the screen stops at > > > D:\Rpackagebuild\Rossi_test>R CMD check test > * checking for working pdflatex ... OK > * using log directory 'D:/Rpackagebuild/Rossi_test/test.Rcheck' > * using R version 2.7.0 (2008-04-22) > * using session charset: ISO8859-1 > * checking for file 'test/DESCRIPTION' ... OK > * this is package 'test' version '0.0' > * checking package name space information ... OK > * checking package dependencies ... OK > * checking if this is a source package ... OK > * checking whether package 'test' can be installed ... > > and the file ooinstal.out shows the following installing > R.css in D:/Rpackagebuild/Rossi_test/test.Rcheck > > -- Making package test > adding build stamp to DESCRIPTION > installing NAMESPACE file and metadata > making DLL ... > making test.d from test.c > gcc -std=gnu99 -Ic:/PROGRA~1/R/R-27~1.0/include -O3 > -Wall -c test.c > -o test.o > > There is subdirectory called ooLOCK under test.Rcheck. > However, there is nothing under it. > > Does anyone have any idea what is going wrong? > > Thanks, > Amanda > > > On Mon, Jun 23, 2008 at 12:23 PM, > <[EMAIL PROTECTED]> wrote: > > > Welcome to the R-help@r-project.org mailing list! > > > > To post to this list, send your email to: > > > > r-help@r-project.org > > > > General information about the mailing list is at: > > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > > If you ever want to unsubscribe or change your options (eg, > switch to > > or from digest mode, change your password, etc.), visit your > > subscription page at: > > > > https://stat.ethz.ch/mailman/options/r-help/xiaohui328%40gmail.com > > > > You can also make such adjustments via email by sending a > message to: > > > > [EMAIL PROTECTED] > > > > with the word `help' in the subject or body (don't include the > > quotes), and you will get back a message with instructions. > > > > You must know your password to change your options > (including changing > > the password, itself) or to unsubscribe. It is: > > > > ets001 > > > > Normally, Mailman will remind you of your r-project.org > mailing list > > passwords once every month, although you can disable this if you > > prefer. This reminder will also include instructions on how to > > unsubscribe or change your account options. There is also > a button on > > your options page that will email your current password to you. > > > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Suppressing output (e.g. from cat)
Many thanks Brian and Hadley, the quiet function works well for me. Maybe a candidate for utils? Best wishes Richard. hadley wickham wrote: Or: tc <- textConnection(NULL, "w") sink(tc) ... sink() close(tc) That is a lot more expensive and subject to o Use of textConnection(NULL, mode="w") could segfault. (NEWS for 2.7.1). Output textConnections are convenient, but have quite a lot of overhead since they need to keep the character vector current. That's true and I hadn't considered the speed issue. It would be nice to have an analogue to capture.output though. Maybe: quiet <- function(x) { sink(tempfile()) on.exit(sink()) invisible(force(x)) } ? Hadley -- Richard D. Pearson [EMAIL PROTECTED] School of Computer Science,http://www.cs.man.ac.uk/~pearsonr University of Manchester, Tel: +44 161 275 6178 Oxford Road, Mob: +44 7971 221181 Manchester M13 9PL, UK.Fax: +44 161 275 6204 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] reset row numbers when extracting a subset of a table
Hi I created a new table by extracting only certain rows of table, but the row numbers in my new table correspond to those from the original table. Is there a way to reset the row numbers in my new table so that they start from one? like below: my table: COL1 COL2 17 v 45 18 b 14 25 x 98 desired: COL1 COL2 1 v 45 2 b 14 3 x 98 Thank you! -Nina __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem when building a test R package on PC
I followed the instruction of building R package on PC by Peter Rossi. I got problem when I tried to build a R package from his example, test.zip. The problem occurs when I tried to R CMD check test the screen stops at D:\Rpackagebuild\Rossi_test>R CMD check test * checking for working pdflatex ... OK * using log directory 'D:/Rpackagebuild/Rossi_test/test.Rcheck' * using R version 2.7.0 (2008-04-22) * using session charset: ISO8859-1 * checking for file 'test/DESCRIPTION' ... OK * this is package 'test' version '0.0' * checking package name space information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK * checking whether package 'test' can be installed ... and the file ooinstal.out shows the following installing R.css in D:/Rpackagebuild/Rossi_test/test.Rcheck -- Making package test adding build stamp to DESCRIPTION installing NAMESPACE file and metadata making DLL ... making test.d from test.c gcc -std=gnu99 -Ic:/PROGRA~1/R/R-27~1.0/include -O3 -Wall -c test.c -o test.o There is subdirectory called ooLOCK under test.Rcheck. However, there is nothing under it. Does anyone have any idea what is going wrong? Thanks, Amanda On Mon, Jun 23, 2008 at 12:23 PM, <[EMAIL PROTECTED]> wrote: > Welcome to the R-help@r-project.org mailing list! > > To post to this list, send your email to: > > r-help@r-project.org > > General information about the mailing list is at: > > https://stat.ethz.ch/mailman/listinfo/r-help > > If you ever want to unsubscribe or change your options (eg, switch to > or from digest mode, change your password, etc.), visit your > subscription page at: > > https://stat.ethz.ch/mailman/options/r-help/xiaohui328%40gmail.com > > You can also make such adjustments via email by sending a message to: > > [EMAIL PROTECTED] > > with the word `help' in the subject or body (don't include the > quotes), and you will get back a message with instructions. > > You must know your password to change your options (including changing > the password, itself) or to unsubscribe. It is: > > ets001 > > Normally, Mailman will remind you of your r-project.org mailing list > passwords once every month, although you can disable this if you > prefer. This reminder will also include instructions on how to > unsubscribe or change your account options. There is also a button on > your options page that will email your current password to you. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Bar charts with error bars
I would like to add error bars to a bar chart, I have created in R. I am able to add error bars to a bar plot, but the same method does not seem to work for my bar chart version.  Is there a way to add error bars to bar charts? Audi, Fiat, Peugeot, Skoda, Porsche, Toyota, Ford - Kelkoo har brugte biler til en hver smag! Klik her for at sammenligne priser.(http://dk.yahoo.com/r/pat/mmb) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Measuring Goodness of a Matrix
on 06/24/2008 09:41 AM Gundala Viswanath wrote: Hi all, Suppose I have 2 matrices A and B. And I want to measure how good each of this matrix is. So I intend to compare A and B with another "gold standard" matrix X. Meaning the more similar a matrix to X the better it is. What is the common way in R to measure matrix similarity (ie. A vs X, and B vs X) ? If I am correctly interpreting what you are looking for see ?dist and perhaps ?hclust. RSiteSearch("matrix similarity") may also prove to be useful. HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Measuring Goodness of a Matrix
Gundala Viswanath wrote: > Hi all, > > Suppose I have 2 matrices A and B. > And I want to measure how good each of this matrix is. > > So I intend to compare A and B with another "gold standard" > matrix X. Meaning the more similar a matrix to X the better it is. > > What is the common way in R to > measure matrix similarity (ie. A vs X, and B vs X) ? > > the (desirably) common way to do that is to read the docs first. ?dist vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Measuring Goodness of a Matrix
Hi all, Suppose I have 2 matrices A and B. And I want to measure how good each of this matrix is. So I intend to compare A and B with another "gold standard" matrix X. Meaning the more similar a matrix to X the better it is. What is the common way in R to measure matrix similarity (ie. A vs X, and B vs X) ? - Gundala Viswanath Jakarta - Indonesia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] insert new columns to a matrix
just cbind the cols in the appropriate order: m.2 = cbind( m.1[,1:5], yourthreecolumns, m.1[,6:ncol(m.1)] ) on 06/24/2008 07:02 AM Daren Tan said the following: Instead of prepend or append new columns to a matrix, how to insert them to a matrix ? For example, I would like to insert 3 new columns after the 5th column of matrix m. _ [[elided Hotmail spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] changing scale range after an axis break
Hello, I am constructing a boxplot but have a very wide range of values (zero - ~28000). I have placed an axis break at the 8000 mark but would like to have a different scale above the break that ranges from 8000-28000. Right now my axis is so large that the boxplots are only represented as lines with the outliers above. Does anyone know where I could find code that explains how to do this? I'd really appreciate it. Thanks! Megan Bellamy __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] bug? nls and "[" indexing
Dear all I just encountered a strange problem with nls formula. I tried to use nls in cycle but I was not successful. I traced the problem to some parse command. Here is an example > DF<-data.frame(x=1:10, y=3*x^.5+rnorm(10)) > coef(lm(log(DF[,2])~log(DF[,1]))) (Intercept) log(DF[, 1]) 0.74373200.6831726 # this works > coef(nls(y~a*x^b, data=DF, start=list(a=3, b=.7))) a b 2.6412881 0.5545907 # OK, this works too > coef(nls(DF[,2]~a*DF[,1]^b, data=DF, start=list(a=3, b=.7))) Error in parse(text = x) : unexpected end of input in "~ " > coef(nls(DF[,2]~a*DF[,1]^b, start=list(a=3, b=.7))) Error in parse(text = x) : unexpected end of input in "~ " # but this does not Maybe it is already resolved in a new version (I will try it) but if not and it is a feature, please help me how to call variables from data frame when using nls inside cycle for (i in ) result[i,] <- coef(nls( , )) Thank you Petr > sessionInfo() R version 2.8.0 Under development (unstable) (2008-05-18 r45723) i386-pc-mingw32 locale: LC_COLLATE=Czech_Czech Republic.1250;LC_CTYPE=Czech_Czech Republic.1250;LC_MONETARY=Czech_Czech Republic.1250;LC_NUMERIC=C;LC_TIME=Czech_Czech Republic.1250 attached base packages: [1] stats grDevices datasets utils graphics methods base other attached packages: [1] nlme_3.1-88lattice_0.17-7 fun_0.1 loaded via a namespace (and not attached): [1] grid_2.8.0 tools_2.8.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Coloring Stripchart Points, or Better, Lattice Equivalent
If anyone remains interested, the solution in base graphics is to modify stripchart.default, the last couple of lines where the coloring of points defaults in a way that depends on groups. In my example, the groups are being handled collectively with the coloring. Code is below. Deepayan has noted that stacking of this type is not possible in Lattice graphics, and would have to be coded directly (probably not too much of a modification of what I give here, but I'm a novice!). Thanks, Bryan stripchart.colsym <- function(x, method="overplot", jitter=0.1, offset=1/3, vertical=FALSE, group.names, add = FALSE, at = NULL, xlim=NULL, ylim=NULL, ylab=NULL, xlab=NULL, dlab="", glab="", log="", pch=0, col=par("fg"), cex=par("cex"), axes=TRUE, frame.plot=axes, ...) { method <- pmatch(method, c("overplot", "jitter", "stack"))[1] if(is.na(method) || method==0) stop("invalid plotting method") groups <- if(is.list(x)) x else if(is.numeric(x)) list(x) if(0 == (n <- length(groups))) stop("invalid first argument") if(!missing(group.names)) attr(groups, "names") <- group.names else if(is.null(attr(groups, "names"))) attr(groups, "names") <- 1:n if(is.null(at)) at <- 1:n else if(length(at) != n) stop(gettextf("'at' must have length equal to the number %d of groups", n), domain = NA) if (is.null(dlab)) dlab <- deparse(substitute(x)) if(!add) { dlim <- c(NA, NA) for(i in groups) dlim <- range(dlim, i[is.finite(i)], na.rm = TRUE) glim <- c(1,n)# in any case, not range(at) if(method == 2) { # jitter glim <- glim + jitter * if(n == 1) c(-5, 5) else c(-2, 2) } else if(method == 3) { # stack glim <- glim + if(n == 1) c(-1,1) else c(0, 0.5) } if(is.null(xlim)) xlim <- if(vertical) glim else dlim if(is.null(ylim)) ylim <- if(vertical) dlim else glim plot(xlim, ylim, type="n", ann=FALSE, axes=FALSE, log=log, ...) if (frame.plot) box() if(vertical) { if (axes) { if(n > 1) axis(1, at=at, labels=names(groups), ...) Axis(x, side = 2, ...) } if (is.null(ylab)) ylab <- dlab if (is.null(xlab)) xlab <- glab } else { if (axes) { Axis(x, side = 1, ...) if(n > 1) axis(2, at=at, labels=names(groups), ...) } if (is.null(xlab)) xlab <- dlab if (is.null(ylab)) ylab <- glab } title(xlab=xlab, ylab=ylab) } csize <- cex* if(vertical) xinch(par("cin")[1]) else yinch(par("cin")[2]) for(i in 1:n) { x <- groups[[i]] y <- rep.int(at[i], length(x)) if(method == 2) ## jitter y <- y + stats::runif(length(y), -jitter, jitter) else if(method == 3) { ## stack xg <- split(x, factor(x)) xo <- lapply(xg, seq_along) x <- unlist(xg, use.names=FALSE) y <- rep.int(at[i], length(x)) + (unlist(xo, use.names=FALSE) - 1) * offset * csize } if(vertical) points(y, x, col=col, pch=pch, cex=cex) else points(x, y, col=col, pch=pch, cex=cex) } } samples <- 100 # must be even index <- round(runif(samples, 1, 100)) # set up data resp <- rbinom(samples, 1, 0.5) yr <- rep(c("2005", "2006"), samples/2) all <- data.frame(index, resp, yr) all$sym <- ifelse(all$resp == 1, 3, 1) all$col <- ifelse(all$yr == 2005, "red", "blue") all$count <- rep(1, length(all$index)) all <- all[order(all$index, all$yr, all$resp),] # for easier inspection row.names(all) <- c(1:samples) # for easier inspection one <- all[(all$yr == 2005 & all$resp == 0),] # First 2005/0 at bottom two <- all[(all$yr == 2005 & all$resp == 1),] # Then 2005/1 three <- all[(all$yr == 2006 & all$resp == 0),] # Now 2006/0 four <- all[(all$yr == 2006 & all$resp == 1),] # Finally 2006/1 par(mfrow = c(5, 1)) par(plt = c(0.1, 0.9, 0.25, 0.75)) stripchart(one$index, method = "stack", ylim = c(0,10), xlim = c(1,100), col = one$col, pch = one$sym) mtext("2005/0 only", side = 3) stripchart(two$index, method = "stack", ylim = c(0,10), xlim = c(1,100), col = two$col, pch = two$sym) mtext("2005/1 only", side = 3) stripchart(three$index, method = "stack", ylim = c(0,10), xlim = c(1,100), col = three$col, pch = three$sym) mtext("2006/0 only", side = 3) stripchart(four$index, method = "stack", ylim = c(0,10), xlim = c(1,100), col = four$col, pch = four$sym) mtext("2006/1 only", side = 3) stripchart.colsym(all$index, method = "stack", ylim = c(0,10), xlim = c(1,100), col = all$col, pch = all$sym) mtext("all data, colored and symbolized as above", side = 3) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] two y-axis using ggplot
Thorsten Vogel staff.hu-berlin.de> writes: > Dear List Members > > As a relatively new R user I am extremely glad for there being a nice > tool such as ggplot for producing easily nice graphs in R. Now I want to > produce graphs with two y-axis. I know that this has been asked a > hundred times with respect to standard plots in R. (The answer, to my > knowledge, has always been "No" or "No, see the help archive".) But: Is > there a more straightforward way IN GGPLOT to draw several lines in one > graphs using two different scales and displaying these two scales on the > y-axis and the, say, z-axis? Seems to be an obvious extensions of > typical plot commands but I can't find any suggestions how to do it. > > Many thanks for any suggestions or hints. > > Best, > Thorsten Don't know the answer for ggplot, but just for the record: the answer to the basic-plot question is "(1) not automatically in base R; (2) see the R wiki for commands to do this in base R without two much trouble; (3) see twoord.plot in the plotrix package; (4) there are lots of good reasons not to do this (again see the R wiki)." cheers Ben Bolker __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Suppressing output (e.g. from cat)
>> Or: >> >> tc <- textConnection(NULL, "w") >> sink(tc) >> ... >> sink() >> close(tc) > > That is a lot more expensive and subject to > >o Use of textConnection(NULL, mode="w") could segfault. > > (NEWS for 2.7.1). Output textConnections are convenient, but have quite a > lot of overhead since they need to keep the character vector current. That's true and I hadn't considered the speed issue. It would be nice to have an analogue to capture.output though. Maybe: quiet <- function(x) { sink(tempfile()) on.exit(sink()) invisible(force(x)) } ? Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] glibc detected error
On Tue, 24 Jun 2008 11:50:44 +0100 (BST), Prof Brian Ripley <[EMAIL PROTECTED]> wrote: >Some compiled code used by your script screwed up the memory allocator, directly or indirectly. But we have no idea what is in 'run.R', and little about your OS, version of R ... see the posting guide. I'm sorry, My OS is Mandriva lxmc216:/home/quintana =>uname -a Linux lxmc216 2.6.12-29mdk-i686-up-4GB #1 Wed Jan 3 10:57:41 MST 2007 i686 AMD Athlon(tm) XP 2800+ unknown GNU/Linux I'm using R version 2.1.1 (2005-06-20) [an old version] I attached the concerned script. What is strange is that this script worked fine some time ago. Thank you in advance. Pere__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Suppressing output (e.g. from cat)
On Tue, 24 Jun 2008, hadley wickham wrote: On Tue, Jun 24, 2008 at 1:15 PM, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: On Tue, 24 Jun 2008, Richard Pearson wrote: Wacek, many thanks! I'm wondering however whether this will be problematic on Windows (I have no windows box to hand to check this, but am creating a package that I would like to be cross-platform)? It will fail. But sink(tempfile()) ... sink() is portable (and sink("nul:") works on Windows only). Or: tc <- textConnection(NULL, "w") sink(tc) ... sink() close(tc) That is a lot more expensive and subject to o Use of textConnection(NULL, mode="w") could segfault. (NEWS for 2.7.1). Output textConnections are convenient, but have quite a lot of overhead since they need to keep the character vector current. Or capture.output(...) Again, expensive. Hadley -- http://had.co.nz/ -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] transform a table into a matrix
Dear Maria, On 23-Jun-08, at 11:40 PM, Maria Gavilanez wrote: Hi. is there a way to transform a table that has numeric and categorical variables into a matrix? No, because all of the elements of a matrix must be of the same mode, but a dataframe is a data structure that can have heterogeneous columns. It's unclear from your question where the "table" is located -- in a file perhaps? If so, you can use read.table() to read the data into a dataframe. I hope this helps, John John Fox, Professor Department of Sociology McMaster University Hamilton ON Canada L8S 4M4 web: socserv.mcmaster.ca/jfox thanks Maria Mercedes Gavilanez Department of Biological Sciences 107 Life Sciences Building Louisiana State University Baton Rouge, LA 70803 (225)578-4284 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Suppressing output (e.g. from cat)
On Tue, Jun 24, 2008 at 1:15 PM, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > On Tue, 24 Jun 2008, Richard Pearson wrote: > >> Wacek, many thanks! I'm wondering however whether this will be problematic >> on Windows (I have no windows box to hand to check this, but am creating a >> package that I would like to be cross-platform)? > > It will fail. But > > sink(tempfile()) > ... > sink() > > is portable (and sink("nul:") works on Windows only). Or: tc <- textConnection(NULL, "w") sink(tc) ... sink() close(tc) Or capture.output(...) Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] sparse matrix and block of R
Dear all, I am writing you for two problems I can not solve with R. I used both the 2.6.1 version and the 2.7.0 version. I run a sintax written by a collegue of mine, where there are involved both sparse matrix and quantile estimations. My data begins with 10008*14 observations and at maximum they reach 10008*834 observations. My questions are the following: first, when I give the command X=as.matrix.csr(X) and in matrix X there are some elements that repeat in some rows (i.e in row 1 there is value 3, in row 2 there is again value 3 in the same position), he gives me the following error: Error in if (nnz == 0) { : valore mancante dove è richiesto TRUE/FALSE (That means : missing value when it is required true/false). When I take off that column with same value that repeats it works well and creates the sparse matrix. Can you help me to correct this problem? Is there a bug in the sparse matrix command? My second problem is the following: after solving this problem I then run a sintax where you run quantile regression repeatedly changing the taus (the quantile estimated). Hence, when I run this program it stops completely sending a microsoft message saying "An error has occurred, the application will be closed" and there is no way to continue to run the program. I thought the problem was the dimension of data, but people told me they are not so huge. Can you help to understand this problem? I tried also on other PC's and gives me the same problem. If the problem is the memory, is there any way to increase it? many thanks alessia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] insert new columns to a matrix
Try something like this: m <- matrix(1:20, ncol = 5) cbind(m[, 1:3], matrix(1:16, ncol = 4), m[,4:ncol(m)]) On Tue, Jun 24, 2008 at 8:02 AM, Daren Tan <[EMAIL PROTECTED]> wrote: > > Instead of prepend or append new columns to a matrix, how to insert them to > a matrix ? For example, I would like to insert 3 new columns after the 5th > column of matrix m. > _ > [[elided Hotmail spam]] > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Suppressing output (e.g. from cat)
On Tue, 24 Jun 2008, Richard Pearson wrote: Wacek, many thanks! I'm wondering however whether this will be problematic on Windows (I have no windows box to hand to check this, but am creating a package that I would like to be cross-platform)? It will fail. But sink(tempfile()) ... sink() is portable (and sink("nul:") works on Windows only). Richard. Wacek Kusnierczyk wrote: Richard Pearson wrote: Is it possible to temporarily suspend output? I am using a function that gives lots of output using cat, that is not very informative. Is it possible to turn output off, run the function, then turn output back on again? I've looked at ?options and done various RSiteSearch()s but couldn't find a way to do this. sink("/dev/null") ?sink vQ -- Richard D. Pearson [EMAIL PROTECTED] School of Computer Science,http://www.cs.man.ac.uk/~pearsonr University of Manchester, Tel: +44 161 275 6178 Oxford Road, Mob: +44 7971 221181 Manchester M13 9PL, UK.Fax: +44 161 275 6204 -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subscripting in data frames with NA
On Tue, 24 Jun 2008, Agustin Lobo wrote: Dear list: Given str(b3) 'data.frame': 159 obs. of 6 variables: $ index_pollution : num 8.228 10.513 0.549 0.915 10.416 ... $ position_descrip: chr "2" "2" "2" NA ... $ position_geo: chr "3" "0" "3" "3" ... $ institution : Factor w/ 3 levels "digesa","mem",..: 3 3 3 3 3 3 3 3 3 3 ... $ p_desc_no3 : chr "2" "2" "2" NA ... $ p_geo_no3 : chr "3" "0" "3" "3" ... I try to subscript but get: b3[b3[,3]=="3",5] <-NA Error in `[<-.data.frame`(`*tmp*`, b3[, 3] == "3", 5, value = NA) : missing values are not allowed in subscripted assignments of data frames Why? What's the correct way of doing this operation? Probably b3[, 3] contains an NA. (It does in the next version) . If so, you want b3[, 3] %in% "3" . Actually, I previously tried with: str(b2) 'data.frame': 159 obs. of 6 variables: $ index_pollution : num 8.228 10.513 0.549 0.915 10.416 ... $ position_descrip: Factor w/ 3 levels "0","1","2": 3 3 3 NA NA NA 3 3 3 3 ... $ position_geo: Factor w/ 4 levels "0","1","2","3": 4 1 4 4 3 NA 3 3 3 4 ... $ institution : Factor w/ 3 levels "digesa","mem",..: 3 3 3 3 3 3 3 3 3 3 ... $ p_desc_no3 : Factor w/ 3 levels "0","1","2": 3 3 3 NA NA NA 3 3 3 3 ... $ p_geo_no3 : Factor w/ 4 levels "0","1","2","3": 4 1 4 4 3 NA 3 3 3 4 ... table(b2$p_desc_no3) 0 1 2 42 44 66 and levels(b2$p_desc_no3)[levels(b2$position_geo)=="3"] <- NA which does not result into error but leaves b2$p_desc_no3 unchanged: table(b2$p_desc_no3) 0 1 2 42 44 66 what am i doing wrong? Thanks Agus -- Dr. Agustin Lobo Institut de Ciencies de la Terra "Jaume Almera" (CSIC) LLuis Sole Sabaris s/n 08028 Barcelona Spain Tel. 34 934095410 Fax. 34 934110012 email: [EMAIL PROTECTED] http://www.ija.csic.es/gt/obster __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Using Huge Pages for R
Hi all, My application usually works on huge amounts of data in the size of MB's .So the performance of "R" in this case will increase if Huge pages are used instead of malloc'ing (as in memory.c) . So Are there any methods to support Huge Pages in "R" ? Can any one give some inputs to help me implementing this feature? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] L-BFGS-B needs finite values of 'fn'
On Tue, 24 Jun 2008, Jinsong Zhao wrote: Another question related with the same code: r <- c(3,4,4,3,5,4,5,9,8,11,12,13) n <- rep(15,12) x <- c(0, 1.1, 1.3, 2.0, 2.2, 2.8, 3.7, 3.9, 4.4, 4.8, 5.9, 6.8) x <- log10(x) fr <- function(c, alpha, beta) { P <- c + (1-c) * pnorm(alpha + beta * x) P <- pmax(pmin(P,1),0) -(sum(log(choose(n,r))) + sum(r * log(P)) + sum((n -r)* log(1-P))) } fit <- mle((fr), start = list(c =0.2, alpha = 0, beta =0.1), method = "BFGS") 0 * (-Inf) = NaN. pnorm(0 + 0*log10(0)) = NaN See my previous answer. The above code could terminate normally. However, if ``beta'' set to 0, then the following error message will appear: Error in optim(start, f, method = method, hessian = TRUE, ...) : initial value in 'vmmin' is not finite I have learn that "drc" package could deal with this situation, it set the first observation to control, however, I don't find the way to implement it in the source code, for the code is too complex to me. Any suggestion? Thanks in advance! You could always try out your own code piece by piece. Jinsong __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] insert new columns to a matrix
Instead of prepend or append new columns to a matrix, how to insert them to a matrix ? For example, I would like to insert 3 new columns after the 5th column of matrix m. _ [[elided Hotmail spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subscripting in data frames with NA
Agustin Lobo wrote: > Dear list: > > Given > > str(b3) > 'data.frame':159 obs. of 6 variables: > $ index_pollution : num 8.228 10.513 0.549 0.915 10.416 ... > $ position_descrip: chr "2" "2" "2" NA ... > $ position_geo: chr "3" "0" "3" "3" ... > $ institution : Factor w/ 3 levels "digesa","mem",..: 3 3 3 3 3 3 > 3 3 3 3 ... > $ p_desc_no3 : chr "2" "2" "2" NA ... > $ p_geo_no3 : chr "3" "0" "3" "3" ... > > I try to subscript but get: > > > b3[b3[,3]=="3",5] <-NA > Error in `[<-.data.frame`(`*tmp*`, b3[, 3] == "3", 5, value = NA) : > missing values are not allowed in subscripted assignments of data > frames Notice that it is not the NA on the right that is the problem, but those in the subscript, so try b3[b3[,3]=="3" | is.na(b3[,3]), 5] <- NA (or ... &!is.na... if that is what you want) > Why? What's the correct way of doing this operation? I forget the exact reason, but as far as I remember, we allowed it at some point, but found that behaviour was inconsistent between differnt modes of subassignment. > Actually, I previously tried with: > > str(b2) > 'data.frame':159 obs. of 6 variables: > $ index_pollution : num 8.228 10.513 0.549 0.915 10.416 ... > $ position_descrip: Factor w/ 3 levels "0","1","2": 3 3 3 NA NA NA 3 > 3 3 3 ... > $ position_geo: Factor w/ 4 levels "0","1","2","3": 4 1 4 4 3 NA > 3 3 3 4 ... > $ institution : Factor w/ 3 levels "digesa","mem",..: 3 3 3 3 3 3 > 3 3 3 3 ... > $ p_desc_no3 : Factor w/ 3 levels "0","1","2": 3 3 3 NA NA NA 3 > 3 3 3 ... > $ p_geo_no3 : Factor w/ 4 levels "0","1","2","3": 4 1 4 4 3 NA > 3 3 3 4 ... > > > table(b2$p_desc_no3) > > 0 1 2 > 42 44 66 > > and > > > levels(b2$p_desc_no3)[levels(b2$position_geo)=="3"] <- NA > > which does not result into error but leaves b2$p_desc_no3 unchanged: > I don't think this makes sense at all. It changes the 4th level of a three-level factor??? > > table(b2$p_desc_no3) > > 0 1 2 > 42 44 66 > > > what am i doing wrong? > > Thanks > > Agus > > > -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Suppressing output (e.g. from cat)
Wacek, many thanks! I'm wondering however whether this will be problematic on Windows (I have no windows box to hand to check this, but am creating a package that I would like to be cross-platform)? Richard. Wacek Kusnierczyk wrote: Richard Pearson wrote: Is it possible to temporarily suspend output? I am using a function that gives lots of output using cat, that is not very informative. Is it possible to turn output off, run the function, then turn output back on again? I've looked at ?options and done various RSiteSearch()s but couldn't find a way to do this. sink("/dev/null") ?sink vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Richard D. Pearson [EMAIL PROTECTED] School of Computer Science,http://www.cs.man.ac.uk/~pearsonr University of Manchester, Tel: +44 161 275 6178 Oxford Road, Mob: +44 7971 221181 Manchester M13 9PL, UK.Fax: +44 161 275 6204 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] L-BFGS-B needs finite values of 'fn'
Another question related with the same code: r <- c(3,4,4,3,5,4,5,9,8,11,12,13) n <- rep(15,12) x <- c(0, 1.1, 1.3, 2.0, 2.2, 2.8, 3.7, 3.9, 4.4, 4.8, 5.9, 6.8) x <- log10(x) fr <- function(c, alpha, beta) { P <- c + (1-c) * pnorm(alpha + beta * x) P <- pmax(pmin(P,1),0) -(sum(log(choose(n,r))) + sum(r * log(P)) + sum((n -r)* log(1-P))) } fit <- mle((fr), start = list(c =0.2, alpha = 0, beta =0.1), method = "BFGS") The above code could terminate normally. However, if ``beta'' set to 0, then the following error message will appear: Error in optim(start, f, method = method, hessian = TRUE, ...) : initial value in 'vmmin' is not finite I have learn that "drc" package could deal with this situation, it set the first observation to control, however, I don't find the way to implement it in the source code, for the code is too complex to me. Any suggestion? Thanks in advance! Jinsong __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R help
A comment from the peanut gallery- It is always good to write an explicative title because it facilitates searching in the forums. thanks Stephen On Tue, Jun 24, 2008 at 6:49 AM, Gustaf Rydevik <[EMAIL PROTECTED]> wrote: > dear Xu, > > does: > >library(urca) > >example(ur.ers) > >ers.gnp > >str(ers.gnp) > >[EMAIL PROTECTED] > > ,do what you want? > (this reminds me that I have to learn S4 sometime) > best, > > Gustaf Rydevik > > > > On Tue, Jun 24, 2008 at 3:52 AM, Xu, Ke-Li <[EMAIL PROTECTED]> wrote: > > Dear Sir/Madam, > > > > I found your email address and your correspondence with R-users. I hope > > you could help me with this question about the function "ur.ers" in the > > package of "urca". It is an improved unit root test (Elliott et al. 1996 > > Econometrica). Do you know how to extract the value of the test > > statistic from the output? The only thing I can get is the print-out of > > all results including the test statistic. But I am wondering whether the > > value is saved somewhere, like g$coef will give you the estimated > > coefficient, where g is a linear model lm object. > > > > Thank you very much. > > > > > > Best regards, > > Keli Xu > > > > > >[[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > > > -- > Gustaf Rydevik, M.Sci. > tel: +46(0)703 051 451 > address:Essingetorget 40,112 66 Stockholm, SE > skype:gustaf_rydevik > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] two y-axis using ggplot
Dear List Members As a relatively new R user I am extremely glad for there being a nice tool such as ggplot for producing easily nice graphs in R. Now I want to produce graphs with two y-axis. I know that this has been asked a hundred times with respect to standard plots in R. (The answer, to my knowledge, has always been "No" or "No, see the help archive".) But: Is there a more straightforward way IN GGPLOT to draw several lines in one graphs using two different scales and displaying these two scales on the y-axis and the, say, z-axis? Seems to be an obvious extensions of typical plot commands but I can't find any suggestions how to do it. Many thanks for any suggestions or hints. Best, Thorsten -- Dr. Thorsten Vogel Institute for Economic Theory II School of Business and Economics Humboldt-Universität zu Berlin Spandauer Str. 1 D-10178 Berlin tel.: +49 (30) 2093 5667 fax: +49 (30) 2093 5696 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] subscripting in data frames with NA
Dear list: Given > str(b3) 'data.frame': 159 obs. of 6 variables: $ index_pollution : num 8.228 10.513 0.549 0.915 10.416 ... $ position_descrip: chr "2" "2" "2" NA ... $ position_geo: chr "3" "0" "3" "3" ... $ institution : Factor w/ 3 levels "digesa","mem",..: 3 3 3 3 3 3 3 3 3 3 ... $ p_desc_no3 : chr "2" "2" "2" NA ... $ p_geo_no3 : chr "3" "0" "3" "3" ... I try to subscript but get: > b3[b3[,3]=="3",5] <-NA Error in `[<-.data.frame`(`*tmp*`, b3[, 3] == "3", 5, value = NA) : missing values are not allowed in subscripted assignments of data frames Why? What's the correct way of doing this operation? Actually, I previously tried with: > str(b2) 'data.frame': 159 obs. of 6 variables: $ index_pollution : num 8.228 10.513 0.549 0.915 10.416 ... $ position_descrip: Factor w/ 3 levels "0","1","2": 3 3 3 NA NA NA 3 3 3 3 ... $ position_geo: Factor w/ 4 levels "0","1","2","3": 4 1 4 4 3 NA 3 3 3 4 ... $ institution : Factor w/ 3 levels "digesa","mem",..: 3 3 3 3 3 3 3 3 3 3 ... $ p_desc_no3 : Factor w/ 3 levels "0","1","2": 3 3 3 NA NA NA 3 3 3 3 ... $ p_geo_no3 : Factor w/ 4 levels "0","1","2","3": 4 1 4 4 3 NA 3 3 3 4 ... > table(b2$p_desc_no3) 0 1 2 42 44 66 and > levels(b2$p_desc_no3)[levels(b2$position_geo)=="3"] <- NA which does not result into error but leaves b2$p_desc_no3 unchanged: > table(b2$p_desc_no3) 0 1 2 42 44 66 what am i doing wrong? Thanks Agus -- Dr. Agustin Lobo Institut de Ciencies de la Terra "Jaume Almera" (CSIC) LLuis Sole Sabaris s/n 08028 Barcelona Spain Tel. 34 934095410 Fax. 34 934110012 email: [EMAIL PROTECTED] http://www.ija.csic.es/gt/obster __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] glibc detected error
On Tue, 24 Jun 2008, pqs wrote: Hello, Today I run a R script that I didn't use for a while (one or two months) and I got an error which I don't understand. source("run.R") *** glibc detected *** double free or corruption (!prev): 0x0809ea98 *** Abandon (core dumped) Does anybody have a clue about the possible source of the error. Some compiled code used by your script screwed up the memory allocator, directly or indirectly. But we have no idea what is in 'run.R', and little about your OS, version of R ... see the posting guide. I think nothing was installed in this computer for many months (I'm not the administrator of my computer). Thank You in advance. Pere __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R help
dear Xu, does: >library(urca) >example(ur.ers) >ers.gnp >str(ers.gnp) >[EMAIL PROTECTED] ,do what you want? (this reminds me that I have to learn S4 sometime) best, Gustaf Rydevik On Tue, Jun 24, 2008 at 3:52 AM, Xu, Ke-Li <[EMAIL PROTECTED]> wrote: > Dear Sir/Madam, > > I found your email address and your correspondence with R-users. I hope > you could help me with this question about the function "ur.ers" in the > package of "urca". It is an improved unit root test (Elliott et al. 1996 > Econometrica). Do you know how to extract the value of the test > statistic from the output? The only thing I can get is the print-out of > all results including the test statistic. But I am wondering whether the > value is saved somewhere, like g$coef will give you the estimated > coefficient, where g is a linear model lm object. > > Thank you very much. > > Best regards, > Keli Xu > > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] L-BFGS-B needs finite values of 'fn'
On Tue, 24 Jun 2008, Jinsong Zhao wrote: Hi, When I run the following code, r <- c(3,4,4,3,5,4,5,9,8,11,12,13) n <- rep(15,12) x <- c(0, 1.1, 1.3, 2.0, 2.2, 2.8, 3.7, 3.9, 4.4, 4.8, 5.9, 6.8) x <- log10(x) So x[1] = -Inf fr <- function(c, alpha, beta) { P <- c + (1-c) * pnorm(alpha + beta * x) P <- pmax(pmin(P,1),0) -(sum(log(choose(n,r))) + sum(r * log(P)) + sum((n -r)* log(1-P))) } fit <- mle((fr), start = list(c =0.2, alpha = 0, beta =0.1), method = "L-BFGS-B") I got: Error in optim(start, f, method = method, hessian = TRUE, ...) : L-BFGS-B needs finite values of 'fn' When I change "L-BFGS-B" to "BFGS" or anything else that optim() support, there's no any error message. What's wrong? What the message says. Your fr() function is returning non-finite values. Look at what happens if P is 0 or 1 for example. You seem to need 0 < c < 1, and you have not imposed that constraint. Adding a trace tp print c(c, alpha, beta) I got [1] 0.2 0.0 0.1 [1] 0.201 0.000 0.100 [1] 0.199 0.000 0.100 [1] 0.200 0.001 0.100 [1] 0.200 -0.001 0.100 [1] 0.200 0.000 0.101 [1] 0.200 0.000 0.099 [1] -0.63692943 -0.54093515 0.01670358 Error in optim(start, f, method = method, hessian = TRUE, ...) : L-BFGS-B needs finite values of 'fn' and other methods also give negative 'c' (and backtrack). There are also problems if beta < 0 (as c + (1-c) * pnorm(alpha + beta * x) = 1 for x = -Inf). So fit <- mle((fr), start = list(c =0.2, alpha = 0, beta =0.1), method = "L-BFGS-B", lower=c(0, -Inf, 0), upper = c(1, Inf, Inf)) works. There is no point in using "L-BFGS-B" in a 3-parameter problem unless you do impose constraints. Also, dbinom() will give a more stable way to compute a binomial log-likelihood. Any suggestions will be appreciated. Jinsong -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Suppressing output (e.g. from cat)
Richard Pearson wrote: > Is it possible to temporarily suspend output? I am using a function > that gives lots of output using cat, that is not very informative. Is > it possible to turn output off, run the function, then turn output > back on again? I've looked at ?options and done various RSiteSearch()s > but couldn't find a way to do this. > sink("/dev/null") ?sink vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop with files
Alfredo Alessandrini wrote: >> can you *explain* what the goal is? >> > > I want import any rwl files (cimfasy.rwl, rocquce.rwl, ...), in a > data.frame with the name like to name of file rwl: > > cimfasy.rwl -> cimfasy > > rocquce.rwl -> rocquce > > with this loop: > > >> library(dplR) >> >> files <- system("ls *.rwl", intern=TRUE) >> >> files >> > [1] "cimfasy.rwl" "rocquce.rwl" > >> for (i in files) {a <- read.rwl(i,header=0)} >> for (file in files) assign(gsub("\\.rwl$", "", file), read.rwl(file, header=0)) ?assign ?gsub vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Suppressing output (e.g. from cat)
Is it possible to temporarily suspend output? I am using a function that gives lots of output using cat, that is not very informative. Is it possible to turn output off, run the function, then turn output back on again? I've looked at ?options and done various RSiteSearch()s but couldn't find a way to do this. Many thanks, Richard. -- Richard D. Pearson [EMAIL PROTECTED] School of Computer Science,http://www.cs.man.ac.uk/~pearsonr University of Manchester, Tel: +44 161 275 6178 Oxford Road, Mob: +44 7971 221181 Manchester M13 9PL, UK.Fax: +44 161 275 6204 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop with files
Alfredo Alessandrini wrote: > I'm trying to make a loop with many files... > > > >> library(dplR) >> >> files <- system("ls *.rwl", intern=TRUE) >> >> files >> > [1] "cimfasy.rwl" "rocquce.rwl" > >> for (i in files) {a <- read.rwl(i,header=0)} >> > There are 70 series > There are 21 series > >> class(a) >> > [1] "data.frame" > > > This loop import all the files rwl in a single data.frame ( a ). > > Can I import a single files to a single data.frame? like this: > > for (i in files) {cimfasy <- read.rwl(i,header=0)} > > for (i in files) {rocquce <- read.rwl(i,header=0)} > > > not easy to get what you really want. the first loop above does read each file separately and place it into a, but at each step it replaces the content of a with a new one. so a contains only the content of the last file, and the whole loop makes no sense. the other two loops do quite the same, just that now you have additional two variables filled with the contents of the same file, the last one on your list. makes no sense either. can you *explain* what the goal is? vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] L-BFGS-B needs finite values of 'fn'
Hi, When I run the following code, r <- c(3,4,4,3,5,4,5,9,8,11,12,13) n <- rep(15,12) x <- c(0, 1.1, 1.3, 2.0, 2.2, 2.8, 3.7, 3.9, 4.4, 4.8, 5.9, 6.8) x <- log10(x) fr <- function(c, alpha, beta) { P <- c + (1-c) * pnorm(alpha + beta * x) P <- pmax(pmin(P,1),0) -(sum(log(choose(n,r))) + sum(r * log(P)) + sum((n -r)* log(1-P))) } fit <- mle((fr), start = list(c =0.2, alpha = 0, beta =0.1), method = "L-BFGS-B") I got: Error in optim(start, f, method = method, hessian = TRUE, ...) : L-BFGS-B needs finite values of 'fn' When I change "L-BFGS-B" to "BFGS" or anything else that optim() support, there's no any error message. What's wrong? Any suggestions will be appreciated. Jinsong __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] loop with files
I'm trying to make a loop with many files... > library(dplR) > > files <- system("ls *.rwl", intern=TRUE) > > files [1] "cimfasy.rwl" "rocquce.rwl" > for (i in files) {a <- read.rwl(i,header=0)} There are 70 series There are 21 series > class(a) [1] "data.frame" This loop import all the files rwl in a single data.frame ( a ). Can I import a single files to a single data.frame? like this: for (i in files) {cimfasy <- read.rwl(i,header=0)} for (i in files) {rocquce <- read.rwl(i,header=0)} Thanks in advance, Alfredo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] glibc detected error
Hello, Today I run a R script that I didn't use for a while (one or two months) and I got an error which I don't understand. >> source("run.R") > *** glibc detected *** double free or corruption (!prev): 0x0809ea98 *** > Abandon (core dumped) Does anybody have a clue about the possible source of the error. I think nothing was installed in this computer for many months (I'm not the administrator of my computer). Thank You in advance. Pere __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.