powered by
Sample a list or vector
list.sample(.data, size, replace = FALSE, weight = 1, prob = NULL)
A list or vector
list
vector
integer. The size of the sample
integer
logical. Should sampling be with replacement?
logical
A lambda expression to determine the weight of each list member, which only takes effect if prob is NULL.
prob
NULL
A vector of probability weights for obtaining the elements of the list being sampled.
# NOT RUN { x <- list(a = 1, b = c(1,2,3), c = c(2,3,4)) list.sample(x, 2, weight = sum(.)) # }
Run the code above in your browser using DataLab