Displaying 1 result from an estimated 1 matches for "writedir".
Did you mean:
write16r
2012 Jun 18
1
Changing many csv files using apply?
...ubset = "somestring"
# Retrieve list of files to change
filelist=list.files()
filelist = filelist[grep(subset, filelist)]
for(i in 1:length(filelist)){
setwd(readdir)
temp = read.csv(filelist[i],as.is = T, strip.white = T)
>whatever I want to do to temp
setwd(writedir)
write.table(temp, file = filelist[i], sep = ",", col.names=NA)
}
It's a little slow though, so I would like to get rid of the for loop but preserve its function. Would it be possible to use sapply() or something similar? Any insight would be appreciated!
Best regards,
Emily