AC3112
August 5, 2021, 9:03am
1
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)
AC3112
August 5, 2021, 9:27am
3
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
system
Closed
August 12, 2021, 9:41am
5
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.