Reputation: 521
Dealing with data saved as integer64 make me wondering if there is a better way. Altough there are discussion in many thread including this one Convert integer64 into integer in R. I still have hard time to find the correct answer.
It's simple question but it becomes annoying for me to handle. For example, I have multiple SQL queries, which come back as a single number of counts. I wanted to take a look at all the numbers but the integer64 formats make it confusing.
I tried to follow the suggestion of converting to double or integer but all failed. Is there a way to do this correctly? I tried following but failed. Any tips?
Not reproducible examples but I provided some examples here.
# suppose I queried multiple time as this one.
usum <- tbl(con,'#other_glucose_pool') %>% tally() %>% as_tibble()
# supposes the count numbers as following:
# usum : 68899
# csum : 732878865
# tsum : 1953359937
# ggg : 1151515151515165
# usum$n
integer64
[1] 68899
# I was trying to get only those ending with sum
needs <- ls()[grep('sum$',ls())]
lapply(needs,function(x) as.double(get(x)))
# result that the scientific notation is still there.
As suggested, I included an example below.
dput(unchgsum)
structure(list(n = structure(5.9575917772475e-319, class = "integer64")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -1L))
nnn <- as.numeric(unchgsum)
nni <- as.integer(unchgsum)
nnd <- as.double(unchgsum)
nnc <- as.character(unchgsum)
# nnn
# [1] 5.957592e-319
# nni
# [1] 0
# nnd
# [1] 5.957592e-319
# nnn
# [1] 5.957592e-319
# nnc
[1] "5.9575917772475e-319"
Upvotes: 0
Views: 497