[R] A vector or array of data frames

Peter Dalgaard p.dalgaard at biostat.ku.dk
Thu Feb 17 14:53:52 CET 2005


"michael watson (IAH-C)" <michael.watson at bbsrc.ac.uk> writes:

> Hi
> 
> A simple question again, but I can't find it by google-ing R-help.
> 
> Quite simply, I want to read in the contents of a number of files, using
> read.table, and assign the results to elements of a
> vector/array/list/whatever.
> 
> I want it so that, if my vector/array/whatever is "pos", that pos[1]
> will give me the first data frame, pos[2] will give me the second etc...

No can do. pos[[1]] etc, however.... (pos[1] is another list, with one
element, in this case the first data frame)

x <- c("fee.dat","foe.dat","fie.dat","fum.dat")
lapply(x, read.table, header=TRUE) # or whatever is needed
 
> Kind of basic stuff I know... Sorry..


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list