[R] Reading multiple files

Silvano Cesar da Costa silvano at uel.br
Wed Sep 26 23:31:48 CEST 2012


Hi,

I didn't notice problems with this.


> Will your data be read in correctly if you do away with the colClasses
> argument to read.delim (or read.table)?
>
> Jean
>
>
>
> "Silvano Cesar da Costa" <silvano at uel.br> wrote on 09/26/2012 09:11:33 AM:
>>
>> Hi,
>>
>> I have 35 data files for reading. I would like get a program for
>> performing reading of 35 files at once.
>> All are of the type: Dados1.raw, Dados2.raw and so on.
>>
>> If the files have the same number of columns, I can read with the
>> following commands:
>>
>> rm(list=ls())
>> filenames = list.files(path="~/Silvano/Arq", pattern="Dados+.*raw")
>> names = substr(filenames, 1, 7)
>>
>> for(i in names){
>>   filepath = file.path("~/Silvano/Dados", paste(i, ".raw", sep=""))
>>   assign(i, read.delim(filepath,
>>                        colClasses=c(rep("character", 5), rep("numeric",
> 5)),
>>                        sep = ""))
>> }
>>
>> It happens that the files have different number of columns. And I can't
>> solve the problem.
>>
>> Any suggestions?
>>
>>
>> ---------------------------------------------
>> Silvano Cesar da Costa
>>
>> Universidade Estadual de Londrina
>> Centro de Ciências Exatas
>> Departamento de Estatística
>>
>> Fone: (43) 3371-4346
>


---------------------------------------------
Silvano Cesar da Costa

Universidade Estadual de Londrina
Centro de Ciências Exatas
Departamento de Estatística

Fone: (43) 3371-4346



More information about the R-help mailing list