[R] how to input multiple .txt files

Mike Lawrence Mike.Lawrence at dal.ca
Mon Mar 30 13:55:03 CEST 2009


my_files = list.files(path=path_to_my_files,pattern='.txt',full.names=TRUE)

a=NULL
for(this_file in my_files){
	a=rbind(a,read.table(this_file))
}
write.table(a,my_new_file_name)




On Sun, Mar 29, 2009 at 10:37 PM, Qianfeng Li <qflichem at yahoo.com> wrote:
>
>
> how to input multiple .txt files?
>
> A data folder has lots of .txt files from different customers.
>
> Want to read all these .txt files to different master files:
>
> such as:
>
>  cust1.xx.txt,  cust1.xxx.txt, cust1.xxxx.txt,.............. to master file: X.txt
>
>  cust2.xx.txt,  cust2.xxx.txt, cust2.xxxx.txt,.............. to master file: Y.txt
>
>
> Thanks!
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

Looking to arrange a meeting? Check my public calendar:
http://tinyurl.com/mikes-public-calendar

~ Certainty is folly... I think. ~




More information about the R-help mailing list