Merges state- and year-level individual item scores - the building
blocks behind the composite indices in stigmaR() - into your dataset.
Use this when you want full flexibility to work with individual items
(e.g., to build and compare your own composites). To create a single
summed composite column directly, see cust_stigmaR().
Arguments
- df
A data frame containing your data.
- state
Character string. Name of the column in
dfcontaining two-letter state abbreviations (e.g., "IL", "CA").- item
Character vector. One or more individual items to merge in. The set of valid items is determined automatically from the columns of the bundled
itemsdataset (everyiat_sex_*mean column, excluding theiat_sex_n_*respondent-count columns). Seenames(stigmaR::items)for the full, current list.- year
Character vector. Years to merge in (e.g.,
c("2016", "2017")). Each year x item combination becomes one new column namedYYYY_itemname(as an example).
Value
The input data frame with new columns named YYYY_itemname
containing matched state-level item scores for each requested year and
item.
Details
To keep merges manageable, a single call is limited to 100 new columns
(i.e., length(item) * length(year)). If you need more than that, split
the request into multiple calls.