[R] Creating directories & folders

Cedrick W. Johnson cedrick at cedrickjohnson.com
Mon Jan 25 00:42:34 CET 2010


I misread the initial problem, sorry (fixing that one with more red 
bull)... Try this:

FUND1 <- "FD1 Q4 2009"
FUND2 <- "FD2 Q4 2009"
MARINE <- "MARINE Q4 2009"

folders <- c(FUND1, FUND2, MARINE)
folders
[1] "FD1 Q4 2009"    "FD2 Q4 2009"    "MARINE Q4 2009"

for (i in 1:length(folders))  {
dir.create(paste(parent.dir,folders[i], sep="/"))
}

-or- a faster way to save keystrokes
folders <- c("FD1 Q4 2009", "FD2 Q4 2009", "MARINE Q4 2009")
for (i in 1:length(folders))  {
dir.create(paste(parent.dir,folders[i], sep="/"))
}

that should work...

cedrick



More information about the R-help mailing list