[R] Save output

Romain Francois francoisromain at free.fr
Mon Oct 3 14:11:11 CEST 2005


Le 03.10.2005 12:30, Frank Schmid a écrit :

> Dear R-Mastermind
>
>
> Within a while or a for-loop, is there a way that I can save to disk the
> results of the previous calculations at the end of each loop with 
> filenames
> called "file01.Rdata", "file02.Rdata" etc?
>
> So far, I have tried to write the outcome of each loop in a 3 dimensional
> array and saved it just once after the loop. Or is there another way 
> so that
> I can keep the resulting matrix of every step in the loop?
>
> Thank you very much for your help
>
>
> Frank Schmid
>  
>
?save
?sprintf

for(i in 1:12){
 tmp <- rnorm(10) # change it with your computations
 save(tmp, file=sprintf('file%02d.RData',i))
}

Romain

-- 
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques
~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
~~~~~~      Romain FRANCOIS - http://addictedtor.free.fr         ~~~~~~
~~~~        Etudiant  ISUP - CS3 - Industrie et Services           ~~~~
~~                http://www.isup.cicrp.jussieu.fr/                  ~~
~~~~           Stagiaire INRIA Futurs - Equipe SELECT              ~~~~
~~~~~~   http://www.inria.fr/recherche/equipes/select.fr.html    ~~~~~~
~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~




More information about the R-help mailing list