how to sample a data frame in R without exhaust the memory

42 views Asked by At

I am trying to sample a data frame which contains two column one is ID one is count. the sum of count is 10^13 and I want to sample the size to 10^12 ,10^11 and so on. but

The vector exceeds the limits of R.

How can I sample this kind of data ?

df_random[[i]]= df2  %>%   mutate(ID=factor(ID)) %>%   %>% 
  tidyr::uncount(count) %>%  sample_n(nrow(.))  %>%
  sample_n(size=round(n/fold2),replace = TRUE) %>%   count(ID, name = "value", .drop=FALSE)
}
0

There are 0 answers