I am a beginner in R so I am sorry if this is too basic. It seems this topic has been covered at How to read data when some numbers contain commas as thousand separator? but I am not sure why I am losing decimals in some examples and not in others.
Specifically, Here's the first example where it works well:
Number2<-c(2345.23568,234.23)
Dollar_Number2<-scales::dollar_format()(Number2)
as.numeric(gsub('[$,]', '', Dollar_Number2))
#output: [1] 2345.24 234.23
However, this one doesn't.
Number1<-c(234523423423.568,234.23)
Dollar_Number1<-scales::dollar_format()(Number1)
as.numeric(gsub('[$,]', '', Dollar_Number1))
#output: [1] 234523423424 234
I have checked options()
for digits, and it seems okay.
I'd appreciate any thoughts.