Re: [R] Convert matrix to numeric

2011-08-03 Thread David Winsemius
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:

Re: [R] Convert matrix to numeric

2011-08-03 Thread Nordlund, Dan (DSHS/RDA)
> -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

Re: [R] Convert matrix to numeric

2011-08-03 Thread Sarah Goslee
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

Re: [R] Convert matrix to numeric

2011-08-03 Thread Ken
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

Re: [R] Convert matrix to numeric

2011-08-03 Thread Duncan Murdoch
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",

[R] Convert matrix to numeric

2011-08-03 Thread Jeffrey Joh
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", "1103", "18", "OPEN", "DEPR", "0.1192871