Learn R Programming

EpiModel (version 0.25)

sampledf: Sample Rows of a Data Frame

Description

This function samples rows from a data frame.

Usage

sampledf(df, size, replace = FALSE, sortby = "")

Arguments

df
data frame to be sampled
size
number of rows to sample
replace
sample with replacement
sortby
sort the data frame by a variable in the data frame

Examples

Run this code
df <- expand.grid(a=0:1, b=0:1, c=0:1)
df$count <- rpois(nrow(df), 5)
df2 <- expanddf(df, df$count)
( df3 <- sampledf(df2, size=5, replace=FALSE, sortby='c') )

Run the code above in your browser using DataLab