...@gmail.com wrote:
From: jim holtman jholt...@gmail.com
Subject: Re: [R] Writing a single output file
To: Amy Milano milano_...@yahoo.com
Cc: r-help@r-project.org
Date: Thursday, December 23, 2010, 1:39 PM
This should get you close:
# get file names
setwd('/temp')
fileNames - list.files
apologize for
reverting so late.
Regards
Amy
--- On Thu, 12/23/10, jim holtman jholt...@gmail.com wrote:
From: jim holtman jholt...@gmail.com
Subject: Re: [R] Writing a single output file
To: Amy Milano milano_...@yahoo.com
Cc: r-help@r-project.org
Date: Thursday, December 23, 2010, 1:39 PM
Many ways of doing this and you have to think about efficiency and
logisitcs of different approaches.
If the data is not large, you can read all n files into a list and then
combine. If data is very large, you may wish to read one file at a time,
combining and then deleting it before reading
Dear R helpers!
Let me first wish all of you Merry Christmas and Very Happy New year 2011
Christmas day is a day of Joy and Charity,
May God make you rich in both - Phillips Brooks
##
This should get you close:
# get file names
setwd('/temp')
fileNames - list.files(pattern = file.*.csv)
fileNames
[1] file1.csv file2.csv file3.csv file4.csv
input - do.call(rbind, lapply(fileNames, function(.name){
+ .data - read.table(.name, header = TRUE, as.is = TRUE)
+ # add
input - do.call(rbind, lapply(fileNames, function(.name){
+ .data - read.table(.name, header = TRUE, as.is = TRUE)
+ # add file name to the data
+ .data$file - .name
+ .data
+ }))
You can simplify this a little with plyr:
fileNames - list.files(pattern = file.*.csv)
On Thu, Dec 23, 2010 at 8:07 AM, Amy Milano milano_...@yahoo.com wrote:
Dear R helpers!
Let me first wish all of you Merry Christmas and Very Happy New year 2011
Christmas day is a day of Joy and Charity,
May God make you rich in both - Phillips Brooks
##
7 matches
Mail list logo