say that I have a script that uses read.csv to read a textfile in a
certain directory, then transforming the data a bit and then spit out a
new file in an output directory.
Is it possible to make this universal so the same procedure is made for
all files in a certain directory and also make it
Jonas -
Here's an (untested) idea:
readwrite = function(file,outputdirectory){
dat = read.csv(file)
. . .
write.csv(dat,file =
paste(outputdirectory,sub('\\.csv','.new',file),sep='/'))
}
sapply(list.files('.',pattern='\\.csv$'),readwrite,'/some/location')
It will read
2 matches
Mail list logo