Hoi Vikas,

--On vrijdag 1 oktober 2004 10:50 +0530 Vikas Rawal <[EMAIL PROTECTED]> wrote:

I want to read data from a number of files into R.
Reading individual files one by one requires writing enormous amount of
code that will look something like the following.

Is there a better way of doing this?

These days I'm using the code below to read in each datafile I have, and come out with a single dataframe.

#  Concatenate the raw data files.
(datafiles <- list.files(path="../raw data/", pattern="pp.+\.dat$"))
tst <- do.call('rbind', lapply(datafiles, function(x) read.table(
 paste('../raw data/', x, sep=""), skip=1)))
rm(datafiles)




-- Paul Lemmens NICI, University of Nijmegen ASCII Ribbon Campaign /"\ Montessorilaan 3 (B.01.05) Against HTML Mail \ / NL-6525 HR Nijmegen X The Netherlands / \ Phonenumber +31-24-3612648 Fax +31-24-3616066

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to