[R] Reading a bunch of csv files into R
Rich Shepard
rshepard at appl-ecosys.com
Fri May 25 22:34:36 CEST 2012
On Fri, 25 May 2012, HJ YAN wrote:
> Is there any claver way that I do not have to type in all these hundreds
> names by hand, maybe using a R package or write some code in some other
> languages if it is not too difficult to learn.
I'd put the list of commands in a shell script; e.g.,
# import_files.R
read_csv("file1.csv", header = T, sep = ',')
read_csv("file2.csv", header = T, sep = ',')
etc.
Then, within a R session, run
source("/full/path/to/import_files.R")
or, on the command line,
R CMD BATCH /full/path/name/to/import_files.R
You'll still need to list all the files individually unless you use a
loop. I've not tried that so someone more experienced will advise you on
that.
Rich
More information about the R-help
mailing list