i imported a df with p - values, which are in character. When converting these into numeric with as.numeric, I only get NAs.
df = c("8,333333e-06")
how can I convert these into numeric?
i imported a df with p - values, which are in character. When converting these into numeric with as.numeric, I only get NAs.
df = c("8,333333e-06")
how can I convert these into numeric?
Change ,
to .
with sub
and then use as.numeric
.
as.numeric(sub(",", ".", "8,333333e-06"))
#[1] 8.333333e-06
Maybe this can already be solved when reading in the data by defining the dec sign. In read.table
this would be in his case done by dec = ","
.