Converting Character into Decimalised Numeric

Hi there,

I wish to transform a variable expressed in the default character form in R to a numeric variable, yet preserve the decimalisation.

However, when I use the command 'as.numeric', this seems to remove the decimal places. Anyone know how to preserve them? Would be appreciated.

data$Score <-as.numeric(data$Score)

Hi @AC3112

It would be easier for us if you provided examples of the data you are trying to convert. But you should check out the parse_double() function from the readr package. Your code would be:

data$Score <- readr::parse_number(data$Score)

Thank you @gueyenono.

The variable 'Score' is a continuous numeric variable. I wanted to preserve that if possible.

I'll check out the readr package and the recommended command. Thank you

You're very welcome.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.