matrix not seen as numeric R
dataframe, matrix, r
Solution
use
dims <- dim(m)
m <- as.numeric(m)
dim(m) <- dims
Probably want to wrap the above in a function
`as.matrix` will not necessarily convert any arbitrary data.frame to numeric. eg:
x <- data.frame(LETTERS)
m <- as.matrix(x)
is.numeric(x)
# [1] FALSE
is.character(x)
# [1] TRUE
Problem
So I converted my data frame to as.matrix(df): ``` m<-as.matrix(df) ``` But then: ``` > is.numeric(m) [1] FALSE ``` I even tried to see if a certain single factor in the matrix is numeric: ``` > is.numeric(m[15,15]) [1] FALSE ``` Anyone else had this happen?