I have a column ("rates")which is a factor
with several levels such as:
16 Levels: -0,186% -0,229% -0,326% ...
When I try to convert it to numeric
, NAs are introduced and I can't figure out how to do it properly.
rates=as.numeric(gsub(",", ".", rates))
rates=as.numeric(sub("%", "e-2", rates))
I also tried the following, which was the answer to a similar question, but it does not work either.
rates=as.numeric(gsub("\%", "", rates))
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…