Here's what you _should_ do
1) transpose
2a) as.data.frame
3a) fix the stupid default stringsAsFactor behavior
4a) convert the first 5 columns to numeric
dfrm <- as.data.frame( t( structure(.) ) )
dfrm[, 1:5] <-lapply(dfrm[, 1:5], as.character)
dfrm[, 1:5] <-lapply(dfrm[, 1:5], as.numeric)
Or:
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Ken
> Sent: Wednesday, August 03, 2011 12:13 PM
> To: Jeffrey Joh
> Cc:
> Subject: Re: [R] Convert matrix to numeric
>
> How about
> Matr
Hi Jeffrey,
On Wed, Aug 3, 2011 at 3:04 PM, Jeffrey Joh wrote:
>
> I have a matrix that looks like this:
>
>
> structure(c("0.0376673981759913", "0.111066500741386", "1", "1103",
> "18", "OPEN", "DEPR", "0.0404073656092023", "0.115186044704599",
> "1", "719", "18", "OPEN", "DEPR", "0.066534209669
How about
Matrix[1:5,]=as.numeric(Matrix[1:5,])
-Ken Hutchison
On Aug 3, 2554 BE, at 3:04 PM, Jeffrey Joh wrote:
>
> I have a matrix that looks like this:
>
>
> structure(c("0.0376673981759913", "0.111066500741386", "1", "1103",
> "18", "OPEN", "DEPR", "0.0404073656092023", "0.11518604470459
On 03/08/2011 3:04 PM, Jeffrey Joh wrote:
I have a matrix that looks like this:
structure(c("0.0376673981759913", "0.111066500741386", "1", "1103",
"18", "OPEN", "DEPR", "0.0404073656092023", "0.115186044704599",
"1", "719", "18", "OPEN", "DEPR", "0.0665342096693433", "0.197570061769498",
"1",
5 matches
Mail list logo