[R] Combining many csv files into one and adding a column with an id of each csv file read

Judith Flores juryef at yahoo.com
Tue Apr 8 21:11:10 CEST 2008

Dear R experts,

   I have been looking into the help-pages and old
questions from the R-Help site, but the options
offered there don't seem to work in my case.

  First of all, I am working on Windows XP, using R
version 2.6.2.

  I am attaching two csv files as an example of how
the data I am traying to put together is delivered to
us. On the first row of every csv file is the name of
the file, along with the pathfile. This is what I have
been doing with every csv files (per seprate), which
of course is not the most efficient way to do it;
basically, it reads the csv file, then deletes the
first 3 rows and some columns that we don't need and
finally I add another column that identifies all the
rows of the csv file as belonging to one subject only,
I have to do this for further manipulations with all
the data:


dat<-read.csv(filename, header=F)


  Since I have multiple csv files to read and I need
to have them consolidated in one data frame, how can I
apply the above manipulations to all the csv files and
at the same time put them in one files?

At the end, I need a big data frame that has 4

'Time', 'T1', T2', 'id'

I hope I have provided enough information.

Thank you in advance for your help,


[[elided Yahoo spam]]

More information about the R-help mailing list