Andy,
First of all, thanks for your solution.
When I test your code, it doesn't work. I am not sure if I miss something.
Here is the code I tested:
flist-list.files(path = file.path(, c:\\),pattern=[.]csv$)
csvlist-lapply(flist, read.csv, header = TRUE)
Here is the error:
Error in file(file,
2006/10/29, Wensui Liu [EMAIL PROTECTED]:
Andy,
First of all, thanks for your solution.
When I test your code, it doesn't work. I am not sure if I miss something.
Here is the code I tested:
flist-list.files(path = file.path(, c:\\),pattern=[.]csv$)
First of all, I think the command should be
Dear All,
I am given a set of files names as:
velocity1.txt
velocity2.txt
and so on.
I am sure there must be a way to read them automatically in R.
It is really taking me longer to read them than to analyze them.
Anybody has a suggestion to help me out with this?
Many thanks
Lorenzo
On Wed, 2006-10-18 at 17:09 +0200, Lorenzo Isella wrote:
Dear All,
I am given a set of files names as:
velocity1.txt
velocity2.txt
and so on.
I am sure there must be a way to read them automatically in R.
It is really taking me longer to read them than to analyze them.
Anybody has a
See ?read.table and the FAQs on importing data
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Lorenzo Isella
Sent: Wednesday, October 18, 2006 11:09 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Automatic File Reading
Dear All,
I am given
Just to complete: if you need them all at the same time:
for(i in 1:100)
{
fn - paste(velocity,i,.txt,sep=)
varname - paste(velocity,i,sep=)
assign(varname,read.csv(fn))
}
and you have a list of objects {velocity1, ..., velocity100} with
corresponding data.
Scionforbai
There have been many threads on this topic.
The posting guide would suggest you do something like this before posting
to the list:
RSiteSearch(reading many files)
Which reveals many relevant threads, such as:
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/84176.html
18, 2006 12:04 PM
To: Lorenzo Isella
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Automatic File Reading
Just to complete: if you need them all at the same time:
for(i in 1:100)
{
fn - paste(velocity,i,.txt,sep=)
varname - paste(velocity,i,sep=)
assign(varname,read.csv(fn
is there a similar way to read all txt or csv files with same
structure from a folder?
thanks.
On 10/18/06, Jerome Asselin [EMAIL PROTECTED] wrote:
On Wed, 2006-10-18 at 17:09 +0200, Lorenzo Isella wrote:
Dear All,
I am given a set of files names as:
velocity1.txt
velocity2.txt
and
Wensui Lui asks:
is there a similar way to read all txt or csv files with same
structure from a folder?
On Windows I use this construct to find all files with the specified wild card
name.
I used the \\ in the file paths with the translate=FALSE, because the / in
the DOS switches /w/B must
Works on all platforms:
flist - list.files(path=file.path(somedir, somewhere),
pattern=[.]csv$)
csvlist - lapply(flist, read.csv, header=TRUE)
whateverList - lapply(csvlist, whatever)
Andy
From: Richard M. Heiberger
Wensui Lui asks:
is there a similar way to read all
Sean Davis wrote:
If you simply want read all files in a given directory, you can do
something like:
fullpath = /home/andersm/tmp
filenames - dir(fullpath,pattern=*)
pair - sapply(filenames,function(x)
{read.table(paste(fullpath,'/',x,sep=))})
Slightly off-topic but it is more portable to use
Hi,
I want to do automatic reading of a number of tables (files) stored in
ascii format
without having to specify the variable name in R each time. Below is an
example
of how I would like to use it (I assume files pair1,...,pair8 exist in
spec. dire.)
for (i in 1:8){
name -
for(i in 1:10){ assign( paste(data, i), i ) }
data1
[1] 1
data5
[1] 5
data8 + data5
[1] 13
See help(assign) for more details and examples.
On Wed, 2004-11-24 at 11:10, Anders Malmberg wrote:
Hi,
I want to do automatic reading of a number of tables (files) stored in
ascii format
Anders Malmberg wrote:
Hi,
I want to do automatic reading of a number of tables (files) stored in
ascii format
without having to specify the variable name in R each time. Below is an
example
of how I would like to use it (I assume files pair1,...,pair8 exist in
spec. dire.)
for (i in 1:8){
Hi Andreas,
what's about:
pair - list()
for (i in 1:8){
name - paste(pair,i,sep=)
pair[[ i ]] - read.table(paste(/home/andersm/tmp/,name,sep=))
}
Arne
On Wednesday 24 November 2004 12:10, Anders Malmberg wrote:
Hi,
I want to do automatic reading of a number of tables (files) stored in
If you simply want read all files in a given directory, you can do
something like:
fullpath = /home/andersm/tmp
filenames - dir(fullpath,pattern=*)
pair - sapply(filenames,function(x)
{read.table(paste(fullpath,'/',x,sep=))})
Sorry, untested. But the point is that you can use dir to get all
17 matches
Mail list logo