I would use 'lapply' to create a list of the matrices: result <- lapply(c(10,20,30,40,50), function(.num){ do.call(cbind, lapply(c('Tableanalysis_firenze', 'Tableanalysis_siena', 'Tableanalysis_lucca'), function(.file){ read.table(sprintf("%s_%d.txt", .file, .num), header=TRUE) })) })
On Thu, Apr 9, 2009 at 10:49 AM, Alessandro <alessandro.monta...@unifi.it> wrote: > Dear R users, > > > > thank for help. SORRY I am seeing in google a maillist but I didn't find a > solution for my problem > > > > I have several txt file (with the same number of column and HEADER) to merge > together, this is an example: > > > > Tableanalysis_firenze_10.txt > > Tableanalysis_firenze_20.txt > > Tableanalysis_firenze_30.txt > > Tableanalysis_firenze_40.txt > > Tableanalysis_firenze_50.txt > > Tableanalysis_siena_10.txt > > Tableanalysis_siena_20.txt > > Tableanalysis_siena_30.txt > > Tableanalysis_siena_40.txt > > Tableanalysis_siena_50.txt > > Tableanalysis_lucca_10.txt > > Tableanalysis_lucca_20.txt > > Tableanalysis_lucca_30.txt > > Tableanalysis_lucca_40.txt > > Tableanalysis_lucca_50.txt > > > > I wish to combine a new txt file like this > > > > Tableanalysis_10 <- cbind(Tableanalysis_firenze_10, Tableanalysis_siena_10, > Tableanalysis_lucca_10) > > Tableanalysis_20 <- cbind(Tableanalysis_firenze_20, Tableanalysis_siena_20, > Tableanalysis_lucca_20) > > Tableanalysis_30 <- cbind(Tableanalysis_firenze_30, Tableanalysis_siena_30, > Tableanalysis_lucca_30) > > Tableanalysis_40 <- cbind(Tableanalysis_firenze_40, Tableanalysis_siena_40, > Tableanalysis_lucca_40) > > Tableanalysis_50 <- cbind(Tableanalysis_firenze_50, Tableanalysis_siena_50, > Tableanalysis_lucca_50) > > > > Thanks > > > > Ale > > > > > > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? ______________________________________________ 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.