merge_strata: Merge Strata

View source: R/merge_strata.R

merge_strataR Documentation

Merge Strata

Description

Merges multiple pre-defined sampling strata into a single stratum.

Usage

merge_strata(data, strata, merge, name = NULL)

Arguments

data

a dataframe or matrix with one row for each sampling unit, one column, strata, specifying each unit's current stratum, and any other relevant columns.

strata

a character string specifying the name of the column that defines each unit's current strata.

merge

the names of the strata to be merged, exactly as they appear in strata.

name

a character name for the new stratum. Defaults to NULL, which pastes the old strata names together to create the new stratum name.

Value

Returns the input dataframe with a new column named 'new_strata' that holds the name of the stratum that each sample belongs to after the merge. The column containing the previous strata names is retained and given the name 'old_strata'.

Examples

x <- merge_strata(iris,
  strata = "Species",
  merge = c("virginica", "versicolor"), name = "v_species"
)

optimall documentation built on June 22, 2024, 9:34 a.m.