Dear all, I have many csv files whose contents I want to change a bit en masse. So far, I've written code that can change them in a for loop, like so:
# Subset of files in the folder I want to change subset = "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 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.