View source: R/compute_lodes_change.R
| compute_lodes_change | R Documentation |
Computes absolute and percentage change in LODES variables between two years for each geographic unit. This is particularly useful for tracking shifts in employment, industrial composition, or earnings structure over time.
Percentage change is computed as
(\text{compare} - \text{base}) / \text{base} \times 100.
Returns NA where base_value is zero or missing.
compute_lodes_change(
lodes_df,
geo_col = NULL,
base_year = NULL,
compare_year = NULL,
variables = NULL,
output = c("wide", "long")
)
lodes_df |
A data frame (tibble) of LODES data covering at least two
years, as returned by |
geo_col |
The name of the geography column to group by, e.g.
|
base_year |
The reference year for computing change. Defaults to the
earliest year present in |
compare_year |
The target year for computing change. Defaults to the
latest year present in |
variables |
Optional character vector of numeric column names to
include in the output. Defaults to all numeric columns (excluding |
output |
One of |
A tibble of change statistics. In "wide" format, columns follow
the pattern {variable}_base, {variable}_compare,
{variable}_change, and {variable}_pct_change. In "long" format,
columns are variable, base_value, compare_value, change, and
pct_change.
## Not run:
wac_multi <- grab_lodes(
state = "md", year = c(2015, 2019),
lodes_type = "wac", job_type = "JT00",
segment = "S000", agg_geo = "county"
)
compute_lodes_change(wac_multi, geo_col = "w_county")
# Long format
compute_lodes_change(
wac_multi,
geo_col = "w_county",
output = "long",
variables = c("C000", "CE01", "CE02", "CE03")
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.