Home > other >  R read_delim() changes values when reading data
R read_delim() changes values when reading data

Time:02-25

I am trying to read in a tabstop seperated csv file using read_delim(). For some reason the function seems to change some field entries in integer values:

# Here some example data
# This should have 3 columns and 1 row 
file_string = c("Tage\tID\tVISITS\n19.02.01\t2163994407707046646\t40")

# reading that data using read_delim()
data = read_delim(file_string, delim = "\t")

view(data)
data$ID
2163994407707046656 # This should be 2163994407707046646 

I totally do not understand what is happening here. If I chnage the col type to character the entry stays the same. Does anyone has an explanation for this?

Happy about any help!

CodePudding user response:

Your number has so many digits, that it does not fit into the R object. According to the specification IEEE 754, the precision of double is 53 bits which is approx. a number with 15 decimal digits. You reach that limit using as.double("2163994407707046646").

  • Related