[R] how to input multiple .txt files

Mike Lawrence Mike.Lawrence at dal.ca
Mon Mar 30 17:33:52 CEST 2009


To repent for my sins, I'll also suggest that Hadley Wickham's "plyr"
package (http://had.co.nz/plyr/) is also useful/parsimonious in this
context:

a <- ldply(cust1_files,read.table)


On Mon, Mar 30, 2009 at 9:32 AM, baptiste auguie <ba208 at exeter.ac.uk> wrote:
> 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
> ______________________________
>
>



-- 
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