Skip to content
Prev 267532 / 398503 Next

Convert matrix to numeric

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:
1) transpose
2b) as.data.frame with stringsAsFactors= FALSE
3b) convert to numeric
On Aug 3, 2011, at 3:04 PM, Jeffrey Joh wrote:

            
David Winsemius, MD
West Hartford, CT