sample_nvoters | R Documentation |
Custom wrapper around dplyr::sample_n
and dplyr::sample_frac
.
Instead of taking samples of rows, it takes a sample of voters defined by
voters (elec, voter_id
) or precincts(elec, precinct_id
).
This is Useful for long-form datasets where each row is an
vote for a particular office by a person.
sample_nvoters(tbl, n)
sample_fvoters(tbl, frac)
sample_nprecincts(tbl, n)
sample_fprecincts(tbl, frac)
tbl |
the dataset that has the columns |
n |
Number of voters or precincts to sample |
frac |
Fraction of voters or precicts to sample. Alternative to |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.