[R] how to input multiple .txt files

baptiste auguie ba208 at exeter.ac.uk
Mon Mar 30 14:32:21 CEST 2009


may i suggest the following,


a <- do.call(rbind, lapply(cust1_files, read.table))

(i believe expanding objects in a for loop belong to the R Inferno)

baptiste

On 30 Mar 2009, at 12:58, Mike Lawrence wrote:

>
> cust1_files =  
> list.files(path=path_to_my_files,pattern='cust1',full.names=TRUE)
> a=NULL
> for(this_file in cust1_files){
>       a=rbind(a,read.table(this_file))
> }
> write.table(a,'cust1.master.txt')

_____________________________

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag




More information about the R-help mailing list