I want to take a sample from a data.table larger than the integer limit of R (available via .Machine$integer.max
). Here is what I have tried:
library(bit64)
library(data.table)
irisdt <- as.data.table(iris)
test <- slice_sample(irisdt, n = .Machine$integer.max + 100, weight_by = Sepal.Length, replace = T)
Fehler in sample.int(n, size, prob = wt, replace = TRUE) :
ungültiges 'size' Argument (= invalid argument 'size')
Zusätzlich: Warnmeldung:
In sample.int(n, size, prob = wt, replace = TRUE) :
NAs introduced by coercion to integer range
If I convert the n
argument to slice_sample
to integer64, I get an empty sample.
> test <- slice_sample(irisdt, n = as.integer64(.Machine$integer.max + 100),
weight_by = Sepal.Length, replace = T)
> nrow(test)
[1] 0
I cannot take several smaller samples which would be an obvious solution to the problem.
Do you have any other ideas? Thank you!