Learn R Programming

rlist (version 0.2.2)

list.sample: Sample a list

Description

Sample a list

Usage

list.sample(.data, size, replace = FALSE, weight = 1, prob = NULL)

Arguments

.data
list
size
integer. The size of the sample
replace
logical. Should sampling be with replacement?
weight
A lambda expression to determine the weight of each list member, which does only takes effect if prob is NULL.
prob
A vector of probability weights for obtaining the elements of the list being sampled.

Examples

Run this code
x <- lapply(1:3,function(i) { c(a=i,b=i^2)})
df <- lapply(1:3,function(i) { data.frame(a=i,b=i^2,c=letters[i])})
list.rbind(x)
list.rbind(df)

Run the code above in your browser using DataLab