Hi !! I need to generate plots from several multiple file and I am doing this by reading it as a list using c(file1, file2.....). Since I need to either print the plots or save it as an plot image while generating the plots in a loop, has anyone done this before. Also is there a getchar() equivalent in R, I mean just to wait for an input from the console so that I can print before it plots the next plot. Thanks ../Murli
T. Murlidharan Nair <nair <at> sdsc.edu> writes:> > Hi !! > I need to generate plots from several multiple file and I am doing this > by reading it as a list using c(file1, file2.....). > Since I need to either print the plots or save it as an plot image while > generating the plots in a loop, has anyone > done this before. Also is there a getchar() equivalent in R, I mean just > to wait for an input from the console so that > I can print before it plots the next plot. > Thanks ../Murli > > ______________________________________________ > R-help <at> stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > >The first example directs output to tmp.pdf while the second waits for input "y". The fun() function throws an error if anything but "y" is input and ends execution (not pretty). tempDat <- lapply( 1:10, function(x) list( x= rnorm(10), y = rnorm(10))) pdf( "tmp.pdf" ) lapply( tempDat , function( inDat ){ plot( inDat$x, inDat$y ) } ) dev.off() fun <- function() { ANSWER <- readline("Next Plot (y=continue else break)") if (substr(ANSWER, 1, 1) != "y") stop("Ending routine\n") } lapply( tempDat , function( inDat ){ plot( inDat$x, inDat$y ) fun() } )
On Mon, 11 Oct 2004, T. Murlidharan Nair wrote:> I need to generate plots from several multiple file and I am doing thisI presume you are making plots from *data* in those files rather than R scripts, but you did not say.> by reading it as a list using c(file1, file2.....). > Since I need to either print the plots or save it as an plot image while > generating the plots in a loop, has anyone > done this before.Yes. (I have no idea what you really want to know here, so am answering the question you actually asked. Please read the posting guide and its references and try to ask smarter questions.)> Also is there a getchar() equivalent in R, I mean just > to wait for an input from the console so that > I can print before it plots the next plot.?readline, par(ask=TRUE). However, whilst the console is waiting for input, *you* can print, but you cannot run R commands to print. -- 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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595