Hi, I would like to create a list of data frames that I could access via index manipulation. An array pointer of dataframe... for (i in 1:length(InputFilelist)) { # create data.frame temp <- read.table (file = InputFilelist[i] , header = T, skip = 4) # append data.frame InputDataFrame <<- list(InputDataFrame,temp) } Thanks in advance ! Pascal Rheaume [[alternative HTML version deleted]]
Rheaume.Pascal at hydro.qc.ca writes:> Hi, > > I would like to create a list of data frames that I could access via index > manipulation. An array pointer of dataframe... > > for (i in 1:length(InputFilelist)) > { > # create data.frame > temp <- read.table (file = InputFilelist[i] , header = T, skip = 4) > # append data.frame > InputDataFrame <<- list(InputDataFrame,temp) > } > > Thanks in advance !You don't want to extend the list on every iteration (it involves copying the current contents!). Try this: lapply(InputFilelist, read.table, header=TRUE, skip=4) -- 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
Rheaume.Pascal at hydro.qc.ca wrote:> Hi, > > I would like to create a list of data frames that I could access via index > manipulation. An array pointer of dataframe... > > for (i in 1:length(InputFilelist)) > { > # create data.frame > temp <- read.table (file = InputFilelist[i] , header = T, skip = 4) > # append data.frame > InputDataFrame <<- list(InputDataFrame,temp) > }I think, the following example my help you: InputDataFrame <- NULL for (i in 1:3) { # create data.frame temp <- data.frame(x=1:5, y=rnorm(5)) # append data.frame InputDataFrame <- c(InputDataFrame, list(temp)) } # show the result str(InputDataFrame) -- Thomas P.