I would not count on getting that many digits without loss of precision in the default integer data type. Notice that the integers will actually get coerced to numeric after a certain length. Compare class(12345678L)
(integer) to class(123456789012L)
(numeric with warning). After a little more length you will start to lose precision, regardless of how many digits you are displaying:
option(digits=22) # the max
x <- 1234567890123456789012; x
# [1] 1234567890123456774144 -- whoops!
For larger integers you may want to use a different class such as Big Integer
in gmp
.
library(gmp)
x <- as.bigz("1234567890123456789012345678901234567890")
x <- x + 1 # do some math
write.csv(as.character(x), "bignumber.csv", row.names=FALSE, quote=FALSE)
# csv looks like:
# x
# 1234567890123456789012345678901234567891