Good morning,
I have currently 63 .csv files most of which have lines which look like
01/06/05,23445
Though some files have two numbers beside each date. There are
missing values, and currently the longest file has 318 rows.
(merge() is losing the head and doing runaway memory allocation - but
Hi,
if you would use a list, to collect (append) all your data.frames from
read.csv, you don't have to compute variable names like a1...a66, just
iterate over contents of the list. By using function dir, you can read all
files in a directory in a loop.
Michael
Am Thursday 11 May 2006 10:03
This is what I would try:
csvlist - list.files(pattern=csv$)
bigblob - lapply(csvlist, read.csv, ...)
## Get all dates that appear in any one of them.
all.dates - unique(unlist(lapply(bigblob, [[, 1)))
bigdata - matrix(NA, length(all.dates), length(bigblob))
dimnames(bigdata) - list(all.dates,
] On Behalf Of Liaw, Andy
Sent: Thursday, May 11, 2006 5:50 AM
To: [EMAIL PROTECTED]; r-help
Subject: Re: [R] data input strategy - lots of csv files
This is what I would try:
csvlist - list.files(pattern=csv$)
bigblob - lapply(csvlist, read.csv, ...)
## Get all dates that appear in any one of them
Assuming:
my.files - c(file1.csv, file2.csv, ..., filen.csv)
use read.zoo in the zoo package and merge.zoo (which
can do a multiway merge):
library(zoo)
do.call(merge, lapply(my.files, read.zoo, ...any.other.read.zoo.args...))
After loading zoo see:
vignette(zoo)
?read.zoo
?merge.zoo
On
Thank you folks - most helpful as always!
Now I have a bit of studying to do :-) I've never really understood
before how to use lapply (or anyother apply) so this gives me a real
problem relating to my own to work with!
Thanks again,
Sean
On 11/05/06, Gabor Grothendieck [EMAIL PROTECTED]
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Liaw, Andy
Sent: Thursday, May 11, 2006 5:50 AM
To: [EMAIL PROTECTED]; r-help
Subject: Re: [R] data input strategy - lots of csv files
This is what I would try:
csvlist - list.files(pattern=csv$)
bigblob