Skip to contents

Given a vector of 2-char ST abbrevs, and vector of colnames in statestats table (indicator names), return data.frame of state averages

Usage

statestats_means_bystates(
  ST = unique(EJAM::statestats$REGION),
  varnames = names_these,
  PCTILES = "mean"
)

Arguments

ST

vector of 2-char ST abbrevs, or all values can be "USA" to get duplicate rows like found in ejamit()$results_bysite[, names_d_avg]

varnames

vector of colnames in statestats table (indicator names)

PCTILES

"mean"

Value

data.frame of state averages for those, one row per ST provided (can have repeats) and colnames are varnames.

Examples

# \donttest{
# one row per state requested, columns are the indicators
statestats_means_bystates(ST = c("MD", "VA"), varnames = EJAM::names_e[1:3])

# ST may contain repeats (e.g. one entry per site) - rows are kept, not collapsed
statestats_means_bystates(ST = c("MD", "MD", "VA"), varnames = EJAM::names_e[1:3])

# all "USA" gives duplicate rows of US averages, like ejamit()$results_bysite[, names_d_avg]
statestats_means_bystates(ST = c("USA", "USA"), varnames = EJAM::names_d[1:3])

# a single indicator still returns a 1-column data.frame
statestats_means_bystates(ST = c("MD", "VA"), varnames = "pm")
# }