[R] multi read.table function and read.table function not accepting col.names
Wolski
wolski at molgen.mpg.de
Wed May 26 17:20:15 CEST 2004
Hi!
?
1.
?lapply
mydataframelist<- lapply(listwithpathstofile, read.table,col.names=names,na.strings="-999.00")
If you like to do more with the read in table say read.table and than some name assignments
you can also define a own function and pass it to lapply.
(or use the for loop.)
* by the way,by defining the variable names you mask the function names.
2.
Not shure if I understand you problem.
lapply returns a list and not a data.frame
you can access each data.frame by eg. mydataframelist[[1]] etc. separatly
Eryk.
Ps. At 13.5.2004 there where an e-mail exchange concerning reading.tables.
*********** REPLY SEPARATOR ***********
On 5/26/2004 at 2:45 PM Laura Quinn wrote:
>Thank you for your earlier help, I have a couple of related questions.
>
>With the lapply function, is it still possible to assign column names to
>each column of every data frame, again I have tried and it doesn't seem to
>like it..
>
>and is it also possible to assign names to each data frame when I do
>lapply rather than each one being a subset of a larger frame (I don't seem
>to be able to attach these as individual objects).
>
>Thanks again,
>Laura
>
>On Wed, 26 May 2004, Wolski wrote:
>
>> Hi!
>>
>> 1.
>> assuning that names is the vector with the names.
>> try col.names=names instead of "names"
>>
>> 2.
>> Several ways
>> a)
>> use
>> lapply(listwithpathstofiles,read.tabel,remaining, options) //u will get
>it stored in the list.
>> b)
>> or use for loop and append to list. mylist<-list()
>> c)
>> or look
>> ?assing
>> to generate several hundred objects in the envrovment.
>>
>> Sincerely Eryk
>>
>> *********** REPLY SEPARATOR ***********
>>
>> On 5/26/2004 at 12:51 PM Laura Quinn wrote:
>>
>> >I am using R-1.8.0 on Debian.
>> >
>> >I'm trying to read in a large table (1441*16) which currently has no
>> >header line. I have set up a list of column names which is 16 names
>long.
>> >
>> >when i try the following:
>> >
>>
>>myfiledate.01<-read.table("filenamedate.01",row.names=NULL,col.names="names",na.strings="-999.00")
>> >
>> >I am returned with an error saying there are more columsh than column
>> >names. I am sure I have done this successfully in the past so can't
>> >understand the problem. I have done the read.table function without
>> >specifying col.names and it works fine and i end up with a 1441*16
>> >data.frame.
>> >
>> >Also as I have several hundred of these tables to read into R, all
>having
>> >the same dimension and all having the same column names, is it possible
>to
>> >automate R so they will all be read in at once - each table represents a
>> >different days worth of data.
>> >
>> >Thanks
>> >
>> >Laura
>> >
>> >______________________________________________
>> >R-help at stat.math.ethz.ch mailing list
>> >https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>> >PLEASE do read the posting guide!
>http://www.R-project.org/posting-guide.html
>>
>>
>>
>> Dipl. bio-chem. Eryk Witold Wolski @ MPI-Moleculare Genetic
>> Ihnestrasse 63-73 14195 Berlin 'v'
>> tel: 0049-30-83875219 / \
>> mail: wolski at molgen.mpg.de ---W-W----
>http://www.molgen.mpg.de/~wolski
>>
>>
Dipl. bio-chem. Eryk Witold Wolski @ MPI-Moleculare Genetic
Ihnestrasse 63-73 14195 Berlin 'v'
tel: 0049-30-83875219 / \
mail: wolski at molgen.mpg.de ---W-W---- http://www.molgen.mpg.de/~wolski
More information about the R-help
mailing list