[R] merge many files together using R

Rui Barradas ruipbarradas at sapo.pt
Thu Jun 14 09:57:00 CEST 2012


Hello,

Suppose your files list is called 'flist'. And that your files have 
blanks as separators.

dflist <- lapply(flist, read.table, header=TRUE, stringsAsFactors=FALSE)
big <- do.call(rbind, dflist)


You can get a list of all files you want with list.files(). See

?list.files


Hope this helps,

Rui Barradas

Em 14-06-2012 07:09, sathya7priya escreveu:
> I have hundreds of text files which has data like a data frame with three
> columns.The column names are same in all the files.I need to merge all files
> into a single big file.
> My files are like this
> file1
> "new.col" "ppm.p." "freq.p."
> "1_3_diaminopropane" 3.13859 5.67516
> "1_3_diaminopropane" 3.137 6.65388
> "1_3_diaminopropane" 3.13541 8.0142
> "1_3_diaminopropane" 3.13383 9.64184
>
> file2
> "new.col" "ppm.p." "freq.p."
> "1_3_dimethylurea" 4.80643 88.4026
> "1_3_dimethylurea" 2.66393 39.238
>
> file3
> "new.col" "ppm.p." "freq.p."
> "1_amino_1_phenylmethyl_phosphonic_acid" 7.44687 7.1684
> "1_amino_1_phenylmethyl_phosphonic_acid" 4.81412 105.11
>
> I need these files to be combined using a single function or loop.I am
> looking for a command which can combine all files in a given folder.The
> resultant file also should have three columns with the common column names..
> Any one answer for this question pls..
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/merge-many-files-together-using-R-tp4633332.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list