[R] Importing many files

Jens Nieschulze jniesch at gwdg.de
Wed Oct 10 17:19:44 CEST 2001


On Wed, 10 Oct 2001, Felix Tiefenbacher wrote:

> Hello Cracks,
> 
> we want to import 10 x 365 files containing each 7 variables with 1211
> rows. The filenames end with numbers from 1 to 365. We tried a for loop
> to import using read.table but we couldn't create the r objects within
> the loop. We want each file in an own r-objekt (matrix).
> 
> Does anyone know what can be done?
there has been a similar question around August 13
you should look up the mail archive
and/or have a look at list.files()

if you want to do it "manually"
have a look at paste() and assign()

I tried it once as in

for(k in 1:4){
xx<-paste("jens",k,".txt",sep="")
 assign(paste("jens",k,sep=""),read.table(xx,sep=","))
}

have you thought of storing the files in a database and accessing them
from within R?

	Jens

> 
> Thanks, Felix
> 
> --
> 
> Felix Tiefenbacher
> 
> Eidg. Institut für Schnee- und Lawinenforschung
> Abteilung: Lawinendynamik
> Flüelastrasse 11
> CH-7260 Davos Dorf
> 
> Tel: +41 (0)81/417 02 53
> Fax: +41 (0)81/417 01 10
> 
> 
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 

***********************************************************************
Jens Nieschulze

Institute for Forest Biometrics &	Phone: ++49-551-39-12107
Applied Computer Science		Fax  : ++49-551-39-3465
Buesgenweg 4
37077 Goettingen		E-mail: jniesch at uni-forst.gwdg.de
GERMANY				http://www.uni-forst.gwdg.de/~jniesch

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list