Re: R-beta: vectors in dataframe?

Janusz Kawczak (jkawczak@fisher.stats.uwo.ca)
Mon, 27 Apr 1998 18:12:40 -0400 (EDT)


In-Reply-To: <x2emyjc4yp.fsf@biostat.ku.dk>
Date: Mon, 27 Apr 1998 18:12:40 -0400 (EDT)
From: Janusz Kawczak <jkawczak@fisher.stats.uwo.ca>
To: r-help@stat.math.ethz.ch
Subject: Re: R-beta: vectors in dataframe?


On 27-Apr-98 Peter Dalgaard BSA wrote:
> Bill Simpson <wsimpson@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@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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._