I want to take a sample of 400 out of a data frame with 2000 rows, the way to do that is simply
s1 <- sample_n(t, 400)
Now I want to do that 10000 times. I guess boot() is the function to use here to avoid an overload but I don't know what I need to write as the function part to get what I want
boot(t, ?, 10000)
Can anyone more experienced with r help me out here?
CodePudding user response:
You can also replicate
the random sample using sample_n
like this:
library(dplyr)
bind_rows(replicate(10, df %>% sample_n(400), simplify = F))
Please note: change the 10 to 10000 for 10000 times.
Random data
df <- data.frame(v1 = runif(2000, 0, 1))