[R] Bug in colnames of data.frames?
David Forrest
drf5n at maplepark.com
Wed Aug 18 00:36:25 CEST 2004
On Tue, 17 Aug 2004, Arne Henningsen wrote:
> Thank you for all your answers!
>
> I agree with you that it is not a bug. My mistake was that I thought that a
> data frame is similar to a matrix, but as ?data.frame says they "... share
> many of the properties of matrices and of lists".
...
>
> I think the current presentation
> > myData
> var1 var2 var3 xyzzy
> 1 1 5 6 5
> 2 2 6 8 4
> 3 3 7 10 3
> 4 4 8 12 2
>
> is confusing because it is not directly (without another command like str())
> apparent why myData[[ "var1" ]] works fine while myData[[ "xyzzy" ]] does
> not.
In some ways it is a bug -- in the documentation, print.data.frame, or
format.data.frame
Consider assigning a wider dataframe to var4:
myData<-data.frame(matrix(1:12,4),var4=I(data.frame(xyzzy=5:2,plugh=1:4)))
myData # error
class(myData[["var4"]])<-"data.frame"
myData # gives indications of sub-variables by var.xyzzy, var.plugh
myData[["var4.plugh"]] # NULL
myData[["var4"]][["plugh"]]
str(myData)
By the way, is there a way of making such an assignment in one step
without the I() class() hack?
dave
--
Dave Forrest
drf at vims.edu (804)684-7900w
drf5n at maplepark.com (804)642-0662h
http://maplepark.com/~drf5n/
More information about the R-help
mailing list