Re: [R] Automatic File Reading

From: Wensui Liu <liuwensui_at_gmail.com>
Date: Wed 18 Oct 2006 - 18:04:38 GMT

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 <jerome.asselin@crchum.qc.ca> 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 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
>
> Not what you mean by "reading".
> ?read.table
> ?read.csv
> ?scan
> ...
>
> However, consider this example. If you have 100 files, you can do:
>
> for(i in 1:100)
> {
> fn <- paste("velocity",i,".txt",sep="")
> dat <- read.csv(fn)
> # ... do your stuff on "dat" here ...
> }
>
> HTH,
> Jerome
>
> --
> Jerome Asselin, M.Sc., Agent de recherche, RHCE
> CHUM -- Centre de recherche
> 3875 rue St-Urbain, 3e etage // Montreal QC H2W 1V1
> Tel.: 514-890-8000 Poste 15914; Fax: 514-412-7106
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
WenSui Liu
(http://spaces.msn.com/statcompute/blog)
Senior Decision Support Analyst
Cincinnati Children Hospital Medical Center

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Thu Oct 19 11:46:44 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 19 Oct 2006 - 02:30:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.