Reputation: 91
I have imported a dataset which contains large numbers which were automatically converted to exponential notation. Because I had to see the full number, I used options(scipen = 999)
. I discovered that the imported number did not equal the original number from the dataset. For example: 5765949338897345178 was changed to 5765949338897345536.
How can it be that these numbers are not the same? The weird thing is that when I use: which(dim_alias1$id == 5765949338897345536)
and which(dim_alias1$id == 5765949338897345178)
, it returns the same rownumber. How is this possible?
Upvotes: 4
Views: 94
Reputation: 25854
As you are using the variable as an id number, it doesn't need to be numeric. So set the column class to character when reading in.
Example:
dat <- data.frame(id=12345, x=1)
write.table(dat, tmp <- tempfile())
dat2 <- read.table(tmp, colClasses = c(id="character"))
str(dat2)
#'data.frame': 1 obs. of 2 variables:
# $ id: chr "12345"
# $ x : int 1
Upvotes: 3