I'm trying to filter by a column which has a "numeric" type already, but it keeps telling me its not meaningful to compare it using ">".
Answer
We can convert those factor
columns to numeric
library(dplyr)
library(magrittr)
mydata %<>%
mutate_if(is.factor, funs(as.numeric(as.character(.))))
Or using base R
i1 <- sapply(mydata, is.factor)
mydata[i1] <- lapply(mydata[i1], function(x) as.numeric(as.character(x)))
and then the code should work
No comments:
Post a Comment