R-beta: vectors in dataframe?

Janusz Kawczak jkawczak at fisher.stats.uwo.ca
Tue Apr 28 00:12:40 CEST 1998


On 27-Apr-98 Peter Dalgaard BSA wrote:
> Bill Simpson <wsimpson at uwinnipeg.ca> writes:
> 
>> > thingy<-read.table(file="rstuff/output.cif3")
>> > thingy$tau1
>> NULL
>> > thingy[,"tau1"]
>> Error: subscript out of bounds
>> > attach(thingy)
>> > tau1
>> Error: Object "tau1" not found
>>  but
>> > thingy
>> lists the row number, tau1, tau2, p3cond
>> i.e. all the data as 4 cols of numbers (up to row 1601).
> 
> My students keep doing that too... 
> 
> If you look more closely, you'll see that what looks like column names
> are really the first line of observations. You need to tell R that the
> first line of the input file contains the column names
> 
>read.table(.........,header=T)
> 
> should do it. And for a sanity check on your data frames, I suggest to
> make a habit of
> 
> summary(thingy)

or you can control the names of the columns by

read.table(......., col.names=c("tau1",....))

This give you more flexibility with the names (in case you like to rename it).

John. 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail: Janusz Kawczak <jkawczak at fisher.stats.uwo.ca>
finger for the public PGP key
Date: 27-Apr-98
Time: 18:07:12
>>>>>> Windows95 - the world's first NON-operating system. <<<<<<
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list