I have a mixed class dataframe (numeric and factor) where I am trying to convert the entire data frame to numeric. The following illustrates the type of data I am working w
Using dplyr (a bit like sapply..)
df2 <- mutate_all(df1, function(x) as.numeric(as.character(x)))
which gives:
glimpse(df2)
Observations: 4
Variables: 2
$ a 0.01, 0.02, 0.03, 0.04
$ b 2, 4, 5, 7
from your df1 which was:
glimpse(df1)
Observations: 4
Variables: 2
$ a 0.01, 0.02, 0.03, 0.04
$ b 2, 4, 5, 7