[R] diverting output from nested loops

Johannes Huesing johannes at huesing.name
Wed Nov 24 22:43:17 CET 2010


Lara Poplarski <larapoplarski at gmail.com> [Wed, Nov 24, 2010 at 06:14:58PM CET]:

> for (K in ...){
> 
>     ... create object ...
> 
>     topDirName <- as.character(paste("topName", K, sep=""))
>     topDirMake <- dir.create(topDirName)
You may want to insert setwd(topDirName) here.

> 
>     for (L in ...) {
> 
>         subDirName <- as.character(paste("subName", L, sep=""))
>         subDirMake <- dir.create(subDirName)
and setwd(subDirName) here.
> 
>         ... manipulate object ...
> 
>         for (M in ...) {
> 
>             objectName <- as.character(paste("objName", M, ".pdf", sep=""))
> 
>             pdf(objectName)
>             plot(object)
>             dev.off()
>         }
and, accordingly, setwd("..") here
>     }
and here
> }
> 



-- 
Johannes Hüsing               There is something fascinating about science. 
                              One gets such wholesale returns of conjecture 
mailto:johannes at huesing.name  from such a trifling investment of fact.                
http://derwisch.wikidot.com         (Mark Twain, "Life on the Mississippi")



More information about the R-help mailing list