Dear R-help,
I was surprised to find that data.frame() keeps the names of all columns:
> x1 <- structure(1:5, names=1:5)
> x2 <- structure(5:1, names=5:1)
> x3 <- structure(10:6, names=10:6)
> x <- data.frame(x1, x2, x3)
> str(x)
`data.frame': 5 obs. of 3 variables:
$ x1: Named int 1 2 3 4 5
..- attr(*, "names")= chr "1" "2" "3"
"4" ...
$ x2: Named int 5 4 3 2 1
..- attr(*, "names")= chr "5" "4" "3"
"2" ...
$ x3: Named int 10 9 8 7 6
..- attr(*, "names")= chr "10" "9"
"8" "7" ...
I could not find mention of this in ?data.frame. The problem is that when I
extract a column of `x', I would be expected the rownames of the data frame
to be used as the names (and short of that, no names attribute), rather than
the original names. Is this intentional?
Best,
Andy
Andy Liaw, PhD
Biometrics Research PO Box 2000, RY33-300
Merck Research Labs Rahway, NJ 07065
mailto:andy_liaw at merck.com <mailto:andy_liaw at merck.com>
732-594-0820