sp_summary() summarizes sampling frames, design sites, and analysis data. The right-hand of the formula specifies the variables (or factors) to summarize by. If the left-hand side of the formula is empty, the summary will be of the distributions of the right-hand side variables. If the left-hand side of the formula contains a variable, the summary will be of the left-hand size variable for each level of each right-hand side variable. Equivalent to spsurvey::summary(); both are currently maintained for backwards compatibility.

sp_summary(object, ...)

# S3 method for default
sp_summary(object, formula = ~1, onlyshow = NULL, ...)

# S3 method for sp_design
sp_summary(object, formula = ~siteuse, siteuse = NULL, onlyshow = NULL, ...)

Arguments

object

An object to summarize. When summarizing sampling frames, an sf object. When summarizing design sites, an object created by grts() or irs() (which has class sp_design). When summarizing analysis data, a data frame or an sf object.

...

Additional arguments to pass to sp_summary(). If the left-hand side of the formula is empty, the appropriate generic arguments are passed to summary.data.frame. If the left-hand side of the formula is provided, the appropriate generic arguments are passed to summary.default.

formula

A formula. One-sided formulas are used to summarize the distribution of numeric or categorical variables. For one-sided formulas, variable names are placed to the right of ~ (a right-hand side variable). Two sided formulas are used to summarize the distribution of a left-hand side variable for each level of each right-hand side categorical variable in the formula. Note that only for two-sided formulas are numeric right-hand side variables coerced to a categorical variables. If an intercept is included as a right-hand side variable (whether the formula is one-sided or two-sided), the total will also be summarized. When summarizing sampling frames or analysis data, the default formula is ~ 1. When summarizing design sites, siteuse should be used in the formula, and the default formula is ~ siteuse.

onlyshow

A string indicating the single level of the single right-hand side variable for which a summary is requested. This argument is only used when a single right-hand side variable is provided.

siteuse

A character vector indicating the design sites for which summaries are requested in object. Defaults to computing summaries for each non-NULL sites_* list in object.

Value

If the left-hand side of the formula is empty, a named list containing summaries of the count distribution for each right-hand side variable is returned. If the left-hand side of the formula contains a variable, a named list containing five number summaries (numeric left-hand side) or tables (categorical or factor left hand side) is returned for each right-hand side variable.

Author

Michael Dumelle Dumelle.Michael@epa.gov

Examples

if (FALSE) {
data("NE_Lakes")
sp_summary(NE_Lakes, ELEV ~ 1)
sp_summary(NE_Lakes, ~ ELEV_CAT * AREA_CAT)
sample <- grts(NE_Lakes, 100)
sp_summary(sample, ~ ELEV_CAT * AREA_CAT)
}