Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert character argument (decimal number) to numeric in R?

I want to convert for example the number 167009345.8 to 167009345.8.

I have used lots of ways but I have problems.

For example,

x <- "167009345.8"
class(x) <- "numeric"`

the output is 167009346.

But I want the decimal number 167009345.8.

I have used also as.numeric, but I have the same problem.

Could you please help me?

like image 971
Vassilis Chasiotis Avatar asked Oct 14 '25 20:10

Vassilis Chasiotis


1 Answers

options(digits=10)
x<-"167009345.8"
as.numeric(x)
[1] 167009345.8
like image 137
r.bot Avatar answered Oct 17 '25 12:10

r.bot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!