Search code examples
samplesampling

New to R, trying to figure out sampling batches


I created an R dataset based on a Hearthstone deck I used to play, and I am trying to sample a typical starting hand, 4 cards, 100 times and for the life of me I can not figure out how to do this.

RenoLock= c(0,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,6,6,6,6,7,7,7,7)
count= table(RenoLock)
count
RenoLock
barplot(count)

Everywhere I've looked has given me a code similar to sample(RenoLock, 4:100, replace = TRUE, prob = NULL) however, this only ever gives me 4 results. I'm trying to get 100 results, each result being 4 cards in size.


Solution

  • Should you call sample function with size=4 for hundred times, you may use lapply like this.

    lapply(rep(4,100),function(x){sample(RenoLock, size=x, replace = FALSE, prob = NULL)})