[R] Problem with data.frame()
Agustin Lobo
aloboaleu at gmail.com
Fri Nov 21 18:27:31 CET 2008
Given
> str(x)
'data.frame': 5284 obs. of 5 variables:
$ COD : chr "0800101001" "0800101002" "0800101003" "0800101004" ...
$ 0-4 : num 79 215 84 58 127 134 15 122 101 99 ...
$ 5-9 : num 76 180 32 56 81 106 10 112 128 96 ...
$ 10-14: num 68 145 39 46 78 81 8 92 142 107 ...
$ 15-19: num 73 170 49 52 103 77 10 116 129 129 ...
I get
> str(data.matrix(x))
num [1:5284, 1:5] 8e+08 8e+08 8e+08 8e+08 8e+08 ...
- attr(*, "dimnames")=List of 2
..$ : chr [1:5284] "3" "6" "9" "12" ...
..$ : chr [1:5] "COD" "0-4" "5-9" "10-14" ...
Should not data.matrix() return a numeric matrix?
And I'm even more confused by this:
> x2 <- censocatT[,2:5]
> str(x2)
'data.frame': 5284 obs. of 4 variables:
$ 0-4 : num 79 215 84 58 127 134 15 122 101 99 ...
$ 5-9 : num 76 180 32 56 81 106 10 112 128 96 ...
$ 10-14: num 68 145 39 46 78 81 8 92 142 107 ...
$ 15-19: num 73 170 49 52 103 77 10 116 129 129 ...
> str(data.matrix(x2))
num [1:5284, 1:4] 79 215 84 58 127 134 15 122 101 99 ...
- attr(*, "dimnames")=List of 2
..$ : chr [1:5284] "3" "6" "9" "12" ...
..$ : chr [1:4] "0-4" "5-9" "10-14" "15-19"
Thanks for any clarification
Agus
--
Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: Agustin.Lobo at ija.csic.es
http://www.ija.csic.es/gt/obster
More information about the R-help
mailing list