Re: [R] Problem with data.frame()

From: Dieter Menne <dieter.menne_at_menne-biomed.de>
Date: Fri, 21 Nov 2008 10:27:26 -0800 (PST)

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.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 21 Nov 2008 - 18:30:14 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 21 Nov 2008 - 19:31:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive