ind_plots_sample: Individual plots for a (stratified) sample of individuals

ind_plots_sampleR Documentation

Individual plots for a (stratified) sample of individuals

Description

A wrapper around ind_plots that first draws a sample of n individuals (9 by default, enough to fill a 3x3 page) rather than plotting every individual in the dataset. If stratify is provided, the sample is drawn proportionally from each level (or combination of levels) of the tidyselect-ed column(s), so the sample remains as representative as the data and n allow.

Usage

ind_plots_sample(
  xpdb,
  n = 9,
  stratify = NULL,
  seed = NULL,
  facets,
  .problem,
  quiet,
  ...
)

Arguments

xpdb

<xp_xtras> or <xpose_data> object

n

<integer> Number of individuals to sample. Defaults to 9. If fewer individuals than n are available, all of them are used.

stratify

<tidyselect> Optional column(s), other than the id column, to stratify the sample by.

seed

<integer> Optional seed, set (and restored on exit) for reproducible sampling.

facets

As in ind_plots. Defaults to the id column (and stratify column(s), if given) added to xpdb$xp_theme$facets.

.problem

<numeric> Problem number to use.

quiet

<logical> Silence extra output.

...

Passed on to ind_plots

Details

When stratify is used, the stratifying column(s) are appended to the facet formula (in addition to the id column that ind_plots already facets by), so that the stratum each sampled individual belongs to is visible in the plot.

Stratified sample sizes are allocated proportionally to stratum size using the largest-remainder method, so the total sampled always equals ⁠min(n, sum(individuals available across all strata))⁠.

Value

The desired plot

See Also

ind_roc()

Examples

xpdb_x %>% ind_plots_sample(n = 6)
xpdb_x %>% ind_plots_sample(n = 6, stratify = SEX)

xpose.xtras documentation built on Sept. 1, 2026, 5:08 p.m.