On 05-12-2012, at 03:37, Gyanendra Pokharel wrote:

> Hi group,
> 
> I imported  16 data frames using the function "list.files"
> 
> temp <- list.files(path="...........")
> myfiles = lapply(temp, read.table,sep = "")
> 
> Now I have 16 data set imported in R window.
> 
> I want to combine them by row and tried some thing like (Here I am
> considering only 20 columns)
> 
> for(i in 1:16){
>    data<- cbind(myfiles[[i]][,1:20])
> 
> }
> 
> 
> but it returns only first data set. I can combine them using
> 
> data <- cbind(myfiles[[1]][,1:20],myfiles[[2]][1:20],...............)
> 
> But  I want in a loop so that I can make the efficient code.

Slightly guessing what you want.
Toy example

set.seed(123)
mydf <- lapply(1:4,FUN=function(dname) data.frame(x=round(runif(10),2), 
y=round(runif(10),2),z=round(runif(10),2)))
mydf

do.call(cbind,lapply(mydf, function(df) df[,1:2]))


Berend

______________________________________________
R-help@r-project.org 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.

Reply via email to