[R] 'loop FOR' for make plots
Don MacQueen
macq at llnl.gov
Fri Mar 31 00:55:57 CEST 2006
There are undoubtedly many ways to do this.
See the get() function.
for( i in 1:10) {
nm <- paste( 'mp',i,'.lm',sep='')
tmp <- get( nm )
plot( tmp$experimental_response, fitted(tmp) )
abline(0,1)
title(nm)
readline('CR to continue ')
}
And you may need to specify pos or envir in get()
Another way would be to put your outputs from lm in a list, which you
could do at the time you create them, instead of afterwords, as here:
lmout <- list(mp1=mp1.lm, mp2=mp2.lm, mp3=mp3.lm)
lapply(
lmout,
function(ff) { plot(ff$experimental_response,fitted(ff)) ;
abline(0,1) }
)
I haven't tested these precisely; there may be typographical errors.
-Don
At 7:14 PM -0100 3/30/06, klebyn wrote:
>Hello
>
>How to create plots dynamically with results of several analysis ?
>
>I got many outputs from lm fuction like:
>
>mp1.lm mp2.lm mp3.lm mp4.lm mp5.lm ...
>
>I'd like to make experimental versus predicted response plots of all
>analysis
>in a 'for loop':
>
>for( i in 1:10){
>x11()
>
>plot( mp*i*$experimental_response, fitted( mp*i* ) ); abline(0,1)
>
>}
>
>I tried: paste( 'mp', i, sep=''), but it don't work.
>
>
>How to make this reference?
>
>
>Regards
>
>Cleber
>
>______________________________________________
>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
--
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
More information about the R-help
mailing list