I ran into a problem trying to make a plot from a file that's read using source. Basically, I have the following code in a file "plot.R" : library(nlme) data(Loblolly) fm1 <- nlme(height ~ SSasymp(age, Asym, R0, lrc), data = Loblolly, fixed = Asym + R0 + lrc ~ 1, random = Asym ~ 1, start = c(Asym = 103, R0 = -8.5, lrc = -3.3)) windows(6,6) plot(fm1) This code is taken from the help page for 'nlme'. If I cut an paste this code into the console, everything works as expected. However, if I try to execute the code by calling source("plot.R") the plot is never made. Has anyone seen this?> version_ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 5.1 year 2002 month 06 day 17 language R -roger _______________________________ UCLA Department of Statistics rpeng at stat.ucla.edu http://www.stat.ucla.edu/~rpeng -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
ripley@stats.ox.ac.uk
2002-Aug-28 06:39 UTC
[R] sourcing a file with the plot.lme() function
Isn't that a lattice plot? Those need to be printed explicitly. On Tue, 27 Aug 2002, Roger Peng wrote:> I ran into a problem trying to make a plot from a file that's read using > source. Basically, I have the following code in a file "plot.R" : > > library(nlme) > data(Loblolly) > fm1 <- nlme(height ~ SSasymp(age, Asym, R0, lrc), > data = Loblolly, > fixed = Asym + R0 + lrc ~ 1, > random = Asym ~ 1, > start = c(Asym = 103, R0 = -8.5, lrc = -3.3)) > windows(6,6) > plot(fm1) > > This code is taken from the help page for 'nlme'. If I cut an paste this > code into the console, everything works as expected. However, if I try to > execute the code by calling source("plot.R") the plot is never made. Has > anyone seen this? > > > > version > _ > platform i386-pc-mingw32 > arch i386 > os mingw32 > system i386, mingw32 > status > major 1 > minor 5.1 > year 2002 > month 06 > day 17 > language R > > -roger > _______________________________ > UCLA Department of Statistics > rpeng at stat.ucla.edu > http://www.stat.ucla.edu/~rpeng > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-- Brian D. Ripley, ripley at stats.ox.ac.uk 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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
--- Roger Peng <rpeng at stat.ucla.edu> wrote:> I ran into a problem trying to make a plot from a file that's read using > source. Basically, I have the following code in a file "plot.R" : > > library(nlme) > data(Loblolly) > fm1 <- nlme(height ~ SSasymp(age, Asym, R0, lrc), > data = Loblolly, > fixed = Asym + R0 + lrc ~ 1, > random = Asym ~ 1, > start = c(Asym = 103, R0 = -8.5, lrc = -3.3)) > windows(6,6) > plot(fm1) > > This code is taken from the help page for 'nlme'. If I cut an paste this > code into the console, everything works as expected. However, if I try to > execute the code by calling source("plot.R") the plot is never made. Has > anyone seen this?This is caused by not using an explicit print() around the "trellis" object returned by plot(). Unlike conventional graphics, trellis/lattice functions don't actually draw anything; the actual plotting is done by the default print method for the object returned. print(plot(fm1)) should work. Deepayan __________________________________________________ Yahoo! Finance - Get real-time stock quotes -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._