If your previously posted code worked with files all having the same number of columns, and if your data is read in correctly without the colClasses argument, then I think the following code should work.
for(i in names){ filepath = file.path("~/Silvano/Dados", paste(i, ".raw", sep="")) assign(i, read.table(filepath)) } If not, then my guess is the error (what is the error message???) is due to the file referencing or naming. For example, it's not clear to me why you take the substring of the file name, only to paste on the file type suffix later. Jean "Silvano Cesar da Costa" <silv...@uel.br> wrote on 09/26/2012 04:31:48 PM: > > 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" <silv...@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 [[alternative HTML version deleted]]
______________________________________________ R-help@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.