0

I am currently importing a csv file that contains huge positive numbers separated by decimals in a column tb <- read.csv("data.csv",dec = ";")

4,013,054,922
5,208,913,410
5,514,995,512
5,148,498,611
...

this data in R recognizes it as a character type and I cannot do operations

I have tried with

as.numeric(tb$large)
as.long(tb$large)
as.complex(tb$large)

but it returns rows with NA

and also try the gmp library too, to no avail

I appreciate your help

royer
  • 615
  • 1
  • 6
  • 19

1 Answers1

4

Is this what you are looking for?

d <-  c('4,013,054,922','5,208,913,410',
       '5,514,995,512',
       '5,148,498,611')

class(d)
#> [1] "character"
library(stringr)
as.numeric(str_remove_all(d, ','))
#> [1] 4013054922 5208913410 5514995512 5148498611

Created on 2020-06-14 by the reprex package (v0.3.0)

MarBlo
  • 4,195
  • 1
  • 13
  • 27