[R] Problem with data.frame()

Dieter Menne dieter.menne at menne-biomed.de
Fri Nov 21 19:27:26 CET 2008




Agustin Lobo-4 wrote:
> 
> 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?
> 
> 

It does, only the dimnames are non-numeric, and you first column is a little
ugly in floating point because the numbers are so big. Do you really want to
convert these to doubles?

Try
dm= data.matrix(x)
dm[,2]

which probably looks quite good.

Dieter



-- 
View this message in context: http://www.nabble.com/Problem-with-data.frame%28%29-tp20626551p20627068.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list