Question:
I have the following number that I'm importing from a site, I put it as follows so I don't need to put all the data import code
a <- as.character("353.636.000.000")
I would like to turn this into a number, but I'm not getting it
I tried to do as follows, separating the terms by .
and then join again and transform into number, however, it didn't work
temp2 <- strsplit(temp2, ".")
I need it to result in an object a
with a value of 353636000000
Answer:
With stringr
you can do this:
library(tidyverse)
b <- a %>%
str_replace_all(pattern = '[.]', '') %>%
as.numeric()
class(b)
[1] "numeric"