Title: | Help Wrangling American Community Survey Data from tidycensus |
---|---|
Description: | A package with helper functions for working with Census data downloaded with the tidycensus package. |
Authors: | Eli Pousson [aut, cre, cph] |
Maintainer: | Eli Pousson <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1.9003 |
Built: | 2024-11-20 02:51:24 UTC |
Source: | https://github.com/elipousson/getACS |
These simple functions allow validating ACS survey options, getting comparable years for time series analysis, and creating standard labels.
acs_survey_match(survey = "acs5", error_call = caller_env()) acs_survey_sample(survey = "acs5") acs_survey_ts(survey = "acs5", year = 2022, call = caller_env()) acs_survey_label( survey = "acs5", year = 2022, pattern = "{year_start}-{year} ACS {sample}-year Estimates", prefix = "" ) acs_survey_label_table( survey = "acs5", year = 2022, prefix = "", table = NULL, table_label = "Table", sep = ", ", and = " and ", before = "", after = before, end = ".", oxford_comma = TRUE )
acs_survey_match(survey = "acs5", error_call = caller_env()) acs_survey_sample(survey = "acs5") acs_survey_ts(survey = "acs5", year = 2022, call = caller_env()) acs_survey_label( survey = "acs5", year = 2022, pattern = "{year_start}-{year} ACS {sample}-year Estimates", prefix = "" ) acs_survey_label_table( survey = "acs5", year = 2022, prefix = "", table = NULL, table_label = "Table", sep = ", ", and = " and ", before = "", after = before, end = ".", oxford_comma = TRUE )
survey |
ACS survey, "acs5", "acs3", or "acs1". |
error_call |
The execution environment of a currently
running function, e.g. |
year |
Based on the year and survey, |
call |
The execution environment of a currently
running function, e.g. |
pattern |
Pattern passed to |
prefix |
Text to insert before ACS survey label. |
table |
One or more table IDs to include in label or source note. |
table_label |
Label to use when referring to table or tables. A "s" is appended to the end of the table_label if tables is more than length 1. |
sep |
Separator to be inserted between words. |
and |
Character string to be prepended to the last word. |
before , after
|
A character string to be added before/after each word. |
end |
A character string appended to the end of the full label. Defaults to ".". |
oxford_comma |
Whether to insert the separator between the last two elements in the list. |
acs_survey_match("acs1") acs_survey_sample("acs3") acs_survey_ts("acs5", 2020) acs_survey_label() acs_survey_label_table(table = c("B19013", "B01003"))
acs_survey_match("acs1") acs_survey_sample("acs3") acs_survey_ts("acs5", 2020) acs_survey_label() acs_survey_label_table(table = c("B19013", "B01003"))
acs_table_race_iteration()
uses the race_iteration
reference data to
create or validate race iteration codes and create race iteration table IDs.
acs_table_race_iteration(table, codes = NULL, error_call = caller_env())
acs_table_race_iteration(table, codes = NULL, error_call = caller_env())
table |
An ACS table ID string. |
codes |
Character vector of race iteration codes to return. If |
error_call |
The execution environment of a currently
running function, e.g. |
A character vector of variable ID values for a single table.
acs_table_race_iteration("B25003")
acs_table_race_iteration("B25003")
acs_table_variables()
helps to make a vector of variable ID values based on
a table ID string. The returned variable IDs use the format returned by
tidycensus::get_acs()
, e.g. "{table_id}_{line_number}" where the
line_number is a width 3 string prefixed by "0". If variables is NULL
, the
function calls get_acs_metadata()
with metadata = "column"
and returns
all available variables for the table for the supplied year and survey. Note
that the sep
and width
parameters should not be changed if you are
working with data from the \{tidycensus\}
package.
acs_table_variables( table = NULL, variables = NULL, data = NULL, survey = "acs5", year = 2022, sep = "_", width = 3, error_call = caller_env() )
acs_table_variables( table = NULL, variables = NULL, data = NULL, survey = "acs5", year = 2022, sep = "_", width = 3, error_call = caller_env() )
table |
An ACS table ID string. |
variables |
A numeric vector corresponding to the line number of the variables. |
data |
If data is provided and table is |
survey |
Survey, "acs5", "acs3", or "acs1". |
year |
Sample year (between 2006 and 2022). |
sep |
A separator character between the table ID string and variable ID values. |
width |
Variable ID suffix width. |
error_call |
The execution environment of a currently
running function, e.g. |
A character vector of variable ID values for a single table.
acs_table_variables(table = "B15003") acs_table_variables(table = "B15003", variables = c(1:5))
acs_table_variables(table = "B15003") acs_table_variables(table = "B15003", variables = c(1:5))
assign_acs_reliability()
tests the reliability of ACS estimate values based
on the assigned MOE level and adds columns to the output with the reliability
information.
assign_acs_reliability( data, value_col = "estimate", moe_col = "moe", moe_level = 90, type = c("census", "esri"), digits = 2, cv_col = "cv", reliability_col = "reliability" )
assign_acs_reliability( data, value_col = "estimate", moe_col = "moe", moe_level = 90, type = c("census", "esri"), digits = 2, cv_col = "cv", reliability_col = "reliability" )
data |
A data frame with a column of estimate values. Typically created
with |
value_col , moe_col
|
Value and margin of error column names (default to "estimate" and "moe"). |
moe_level |
The confidence level of the margin of error. Defaults to 90
(which is the same default as |
type |
Type of reliability rating to assign. Either "census" (default) or "esri". In both cases, the added reliability column values are "high", "medium", or "low". |
digits |
Number of digits to use for values in the coefficient of
variation column. Passed to |
cv_col |
Coefficient of variation column name. Defaults to "cv". |
reliability_col |
Reliability category column name. Defaults to "reliability". |
A data frame with an added columns using the names assigned to
cv_col
and reliability_col
forcats::fct_collapse()
collapse_acs_variables()
uses forcats::fct_collapse()
to aggregated
variables while creating a new label column. Other variables are retained in
list columns of unique values. The aggregated values for perc_moe
may not
be accurate after transformation with this function. To group by additional
variables, passed a grouped data frame to data and set .add = TRUE
.
collapse_acs_variables( data, ..., other_level = NULL, name_col = "NAME", variable_col = "variable", label_col = "label", value_col = "estimate", moe_col = "moe", moe_level = 90, reliability = FALSE, na.rm = TRUE, na_zero = TRUE, digits = 2, .add = FALSE, extensive = TRUE )
collapse_acs_variables( data, ..., other_level = NULL, name_col = "NAME", variable_col = "variable", label_col = "label", value_col = "estimate", moe_col = "moe", moe_level = 90, reliability = FALSE, na.rm = TRUE, na_zero = TRUE, digits = 2, .add = FALSE, extensive = TRUE )
data |
ACS data frame input. |
... |
< |
other_level |
Value of level used for "other" values. Always placed at end of levels. |
name_col |
Name column name, Default: 'NAME' |
variable_col |
Variable column name, Default: 'variable' |
label_col |
Label column name, Default: 'label'. Label is a factor column added to the returned data frame. |
value_col , moe_col
|
Value and margin of error column names (default to "estimate" and "moe"). |
moe_level |
The confidence level of the margin of error. Defaults to 90
(which is the same default as |
reliability |
If |
na.rm |
Passed to |
na_zero |
If |
digits |
Passed to |
.add |
When This argument was previously called |
extensive |
Must be |
forcats::fct_collapse()
, camiller::add_grps()
## Not run: if (interactive()) { edu_data <- get_acs_tables( "county", table = "B15003", state = "MD", county = "Baltimore city" ) table_vars <- acs_table_variables("B15003") collapse_acs_variables( edu_data, "Total" = table_vars[1], "5th Grade or less" = table_vars[5:9], "6th to 8th Grade" = table_vars[10:12], "9th to 11th Grade" = table_vars[13:15], other_level = "Other" ) } ## End(Not run)
## Not run: if (interactive()) { edu_data <- get_acs_tables( "county", table = "B15003", state = "MD", county = "Baltimore city" ) table_vars <- acs_table_variables("B15003") collapse_acs_variables( edu_data, "Total" = table_vars[1], "5th Grade or less" = table_vars[5:9], "6th to 8th Grade" = table_vars[10:12], "9th to 11th Grade" = table_vars[13:15], other_level = "Other" ) } ## End(Not run)
fmt_acs_county()
is helpful for stripping the state name from county-level
ACS data and fmt_acs_minutes()
does the same for a column with a duration
(e.g. commute times). If data is not a gt_tbl
object, both function can use
dplyr::mutate()
to transform a standard data frame.
fmt_acs_county( data, state = NULL, pattern = ", {state}", replacement = "", name_col = "NAME", columns = all_of(name_col), ... ) fmt_acs_minutes( data, pattern = "[:space:]minutes$", replacement = "", column_title_col = "column_title", columns = all_of(column_title_col), ... )
fmt_acs_county( data, state = NULL, pattern = ", {state}", replacement = "", name_col = "NAME", columns = all_of(name_col), ... ) fmt_acs_minutes( data, pattern = "[:space:]minutes$", replacement = "", column_title_col = "column_title", columns = all_of(column_title_col), ... )
data |
The gt table data object
This is the gt table object that is commonly created through use of the
|
state |
State name. Required if state is included in pattern. |
pattern |
Passed to |
replacement |
Passed to |
name_col |
Name for column with place name values. Defaults to "NAME" |
columns |
Columns to target
Can either be a series of column names provided in |
... |
Arguments passed on to
|
column_title_col |
Column title column. |
fmt_acs_estimate()
formats estimate and margin of error columns for a gt
table created with ACS data. fmt_acs_percent()
does the same for the
perc_estimate and perc_moe columns calculated by join_acs_percent()
. Both
functions are used internally by gt_acs()
.
fmt_acs_estimate( gt_object, col_est = "estimate", col_moe = "moe", columns = NULL, col_labels = "Est.", spanner = NULL, decimals = 0, use_seps = TRUE, ..., call = caller_env() ) fmt_acs_percent( gt_object, col_est = "perc_estimate", col_moe = "perc_moe", columns = NULL, col_labels = "% share", spanner = NULL, decimals = 0, use_seps = TRUE, ..., call = caller_env() ) cols_label_ext( gt_object, columns = NULL, col_labels = NULL, call = caller_env() )
fmt_acs_estimate( gt_object, col_est = "estimate", col_moe = "moe", columns = NULL, col_labels = "Est.", spanner = NULL, decimals = 0, use_seps = TRUE, ..., call = caller_env() ) fmt_acs_percent( gt_object, col_est = "perc_estimate", col_moe = "perc_moe", columns = NULL, col_labels = "% share", spanner = NULL, decimals = 0, use_seps = TRUE, ..., call = caller_env() ) cols_label_ext( gt_object, columns = NULL, col_labels = NULL, call = caller_env() )
gt_object |
A gt object. |
col_est , col_moe
|
Column names for the estimate and margin of error values in the table data. |
columns |
If |
col_labels |
Column name used for one or more columns passed to
|
spanner |
If |
decimals |
Number of decimal places
This corresponds to the exact number of decimal places to use. A value
such as |
use_seps |
Use digit group separators
An option to use digit group separators. The type of digit group separator
is set by |
... |
Additional parameters passed to |
call |
The execution environment of a currently
running function, e.g. |
Using cols_label_ext
cols_label_ext()
is a variant on gt::cols_label()
used by
fmt_acs_estimate()
and fmt_acs_percent()
.
Other gt table:
gt_acs()
,
gt_acs_compare()
,
tab_acs_source_note()
Currently only supports variable B25035_001 from the Median Year Structure Built table.
fmt_acs_jam_values(data)
fmt_acs_jam_values(data)
data |
Data frame with ACS data |
Create a bar chart with ggplot2::geom_col()
and apply an errorbar (using
geom_acs_errorbar), scale (using scale_x_acs or scale_y_acs).
geom_acs_col( mapping = NULL, data = NULL, position = "stack", ..., x = "estimate", y = "column_title", fill = y, value_col = "estimate", moe_col = "moe", perc_prefix = "perc", perc_sep = "_", perc = TRUE, orientation = NA, errorbar_value = TRUE, errorbar_params = list(linewidth = 0.5, height = 0.35, position = "identity"), scale_value = TRUE, scale_params = list() )
geom_acs_col( mapping = NULL, data = NULL, position = "stack", ..., x = "estimate", y = "column_title", fill = y, value_col = "estimate", moe_col = "moe", perc_prefix = "perc", perc_sep = "_", perc = TRUE, orientation = NA, errorbar_value = TRUE, errorbar_params = list(linewidth = 0.5, height = 0.35, position = "identity"), scale_value = TRUE, scale_params = list() )
mapping |
Aesthetic mapping. Recommend leaving this as |
data |
The data to be displayed in this layer. There are three options: If A A |
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
x , y , fill
|
String values with column names mapped to aesthetics.
Optional if |
value_col |
Column name for estimate value column. Defaults to "estimate". |
moe_col |
Column name for margin of error column. Defaults to "moe". |
perc_prefix |
Prefix string for percent value columns. |
perc_sep |
Separator string between |
perc |
If |
orientation |
The orientation of the layer. The default ( |
errorbar_value |
If |
errorbar_params |
Parameters passed to |
scale_value |
If |
scale_params |
Parameters passed to |
These functions wrap tidycensus::get_acs()
and label_acs_metadata()
to
support downloading multiple tables and combining tables into a single data
frame or downloading data for multiple geographies. Note that while the
Census API does not have a specific rate or request limit when using a Census
API key, using these functions with a large number of tables or geographies
may result in errors or failed requests.
CRAN policies require that tidycensus avoid caching by default, however, this
package sets cache_table = TRUE
by default to avoid unecessary load on the
Census API.
get_acs_tables( geography, table = NULL, cache_table = TRUE, year = 2022, survey = "acs5", variables = NULL, moe_level = 90, ..., crs = NULL, label = TRUE, perc = TRUE, reliability = FALSE, keep_geography = TRUE, geoid_col = "GEOID", quiet = FALSE, call = caller_env() ) get_acs_geographies( geography = c("county", "state"), variables = NULL, table = NULL, cache_table = TRUE, year = 2022, state = NULL, county = NULL, msa = NULL, survey = "acs5", ..., label = TRUE, perc = TRUE, geoid_col = "GEOID", quiet = FALSE ) get_acs_geography( geography, variables = NULL, table = NULL, cache_table = TRUE, year = 2022, state = NULL, county = NULL, msa = NULL, survey = "acs5", ..., label = TRUE, perc = TRUE, geoid_col = "GEOID", call = caller_env() )
get_acs_tables( geography, table = NULL, cache_table = TRUE, year = 2022, survey = "acs5", variables = NULL, moe_level = 90, ..., crs = NULL, label = TRUE, perc = TRUE, reliability = FALSE, keep_geography = TRUE, geoid_col = "GEOID", quiet = FALSE, call = caller_env() ) get_acs_geographies( geography = c("county", "state"), variables = NULL, table = NULL, cache_table = TRUE, year = 2022, state = NULL, county = NULL, msa = NULL, survey = "acs5", ..., label = TRUE, perc = TRUE, geoid_col = "GEOID", quiet = FALSE ) get_acs_geography( geography, variables = NULL, table = NULL, cache_table = TRUE, year = 2022, state = NULL, county = NULL, msa = NULL, survey = "acs5", ..., label = TRUE, perc = TRUE, geoid_col = "GEOID", call = caller_env() )
geography |
Required character vector of one or more geographies. See
https://walker-data.com/tidycensus/articles/basic-usage.html#geography-in-tidycensus
for supported options. Defaults to |
table |
A character vector of tables. |
cache_table |
Whether or not to cache table names for faster future
access. Defaults to FALSE; if TRUE, only needs to be called once per
dataset. If variables dataset is already cached via the
|
year |
The year, or endyear, of the ACS sample. 5-year ACS data is available from 2009 through 2022; 1-year ACS data is available from 2005 through 2022, with the exception of 2020. Defaults to 2022. |
survey |
The ACS contains one-year, three-year, and five-year surveys expressed as "acs1", "acs3", and "acs5". The default selection is "acs5." |
variables |
Character string or vector of character strings of variable IDs. tidycensus automatically returns the estimate and the margin of error associated with the variable. |
moe_level |
The confidence level of the returned margin of error. One of 90 (the default), 95, or 99. |
... |
Arguments passed on to
|
crs |
Coordinate reference system to use for returned sf tibble when
|
label |
If |
perc |
If |
reliability |
If |
keep_geography |
If |
geoid_col |
A GeoID column name to use if perc is |
quiet |
If |
call |
The execution environment of a currently
running function, e.g. |
state |
An optional vector of states for which you are requesting data. State names, postal codes, and FIPS codes are accepted. Defaults to NULL. |
county |
The county for which you are requesting data. County names and FIPS codes are accepted. Must be combined with a value supplied to 'state'. Defaults to NULL. |
msa |
Name or GeoID of a metro area that should be filtered from the overall list of metro areas returned when geography or geographies is "metropolitan/micropolitan statistical area", "cbsa", or "metropolitan statistical area/micropolitan statistical area". |
## Not run: if (interactive()) { get_acs_tables( geography = "county", county = "Baltimore city", state = "MD", table = c("B01003", "B19013") ) get_acs_geographies( geography = c("county", "state"), state = "MD", table = c("B01003", "B19013") ) } ## End(Not run)
## Not run: if (interactive()) { get_acs_tables( geography = "county", county = "Baltimore city", state = "MD", table = c("B01003", "B19013") ) get_acs_geographies( geography = c("county", "state"), state = "MD", table = c("B01003", "B19013") ) } ## End(Not run)
get_acs_ts()
is a variant on get_acs_geographies()
that supports
downloading data for multiple years in addition to multiple tables or
multiple geographies. The year is appended as an additional column in the
returned data frame. The intended use is to provide the latest year needed
and the function will download data for all non-overlapping survey periods.
For example, 2021 ACS data using the 5-year sample can be compared to 5-year
data from 2016 and 2011. Not all variables can be compared across different
years and caution is recommended when using ACS data for time series
analysis.
get_acs_ts( geography, variables = NULL, table = NULL, cache_table = TRUE, year = 2022, state = NULL, county = NULL, survey = "acs5", ..., quiet = FALSE )
get_acs_ts( geography, variables = NULL, table = NULL, cache_table = TRUE, year = 2022, state = NULL, county = NULL, survey = "acs5", ..., quiet = FALSE )
geography |
Required character vector of one or more geographies. See
https://walker-data.com/tidycensus/articles/basic-usage.html#geography-in-tidycensus
for supported options. Defaults to |
variables |
Character string or vector of character strings of variable IDs. tidycensus automatically returns the estimate and the margin of error associated with the variable. |
table |
A character vector of tables. |
cache_table |
Whether or not to cache table names for faster future
access. Defaults to FALSE; if TRUE, only needs to be called once per
dataset. If variables dataset is already cached via the
|
year |
A numeric vector of years. If length 1, the function uses
|
state |
An optional vector of states for which you are requesting data. State names, postal codes, and FIPS codes are accepted. Defaults to NULL. |
county |
The county for which you are requesting data. County names and FIPS codes are accepted. Must be combined with a value supplied to 'state'. Defaults to NULL. |
survey |
The ACS contains one-year, three-year, and five-year surveys expressed as "acs1", "acs3", and "acs5". The default selection is "acs5." |
... |
Other keyword arguments |
quiet |
If |
A data frame or sf object.
get_decennial_ts()
is a wrapper for tidycensus::get_decennial()
to handle
time series data.
get_decennial_ts( geography, variables = NULL, table = NULL, cache_table = TRUE, year = 2020, sumfile = NULL, state = NULL, county = NULL, geometry = FALSE, summary_var = NULL, label = TRUE, ... )
get_decennial_ts( geography, variables = NULL, table = NULL, cache_table = TRUE, year = 2020, sumfile = NULL, state = NULL, county = NULL, geometry = FALSE, summary_var = NULL, label = TRUE, ... )
geography |
The geography of your data. |
variables |
If any year value is 2020, variables must be the same length
as year with each value corresponding to one of the years requested. This
is a temporary requirement to address the mismatch between the available
data for 2000 and 2010 relative to 2020.
Default: |
table |
The Census table for which you would like to request all variables. Uses
lookup tables to identify the variables; performs faster when variable
table already exists through |
cache_table |
Whether or not to cache table names for faster future access.
Defaults to FALSE; if TRUE, only needs to be called once per
dataset. If variables dataset is already cached via the
|
year |
If year is length 1, it is treated as the max year and decennial Census years back to 2000, are added to the vector of requested years. Default: 2020 |
sumfile |
The Census summary file; if |
state |
The state for which you are requesting data. State names, postal codes, and FIPS codes are accepted. Defaults to NULL. |
county |
The county for which you are requesting data. County names and FIPS codes are accepted. Must be combined with a value supplied to 'state'. Defaults to NULL. |
geometry |
if FALSE (the default), return a regular tibble of ACS data. if TRUE, uses the tigris package to return an sf tibble with simple feature geometry in the 'geometry' column. |
summary_var |
Character string of a "summary variable" from the decennial Census to be included in your output. Usually a variable (e.g. total population) that you'll want to use as a denominator or comparison. |
label |
If |
... |
Arguments passed on to
|
A data frame with decennial Census data.
## Not run: if (interactive()) { md_counties <- get_decennial_ts( geography = "county", variables = c("P001001", "P001001", "P1_001N"), year = 2020, county = "Baltimore city", state = "MD", geometry = FALSE ) } ## End(Not run)
## Not run: if (interactive()) { md_counties <- get_decennial_ts( geography = "county", variables = c("P001001", "P001001", "P1_001N"), year = 2020, county = "Baltimore city", state = "MD", geometry = FALSE ) } ## End(Not run)
Create or format a gt table with an estimate and margin of error and
(optionally) percent estimate and margin of error value. Use in combination
with the select_acs()
helper function to prep data before creating a
table.
gt_acs( data, rownames_to_stub = FALSE, row_group_as_column = FALSE, ..., value_col = "estimate", moe_col = "moe", perc_prefix = "perc", perc_sep = "_", perc = FALSE, column_title_col = "column_title", name_col = "NAME", perc_value_label = "% share", value_label = "Est.", column_title_label = NULL, name_label = NULL, est_spanner = NULL, perc_spanner = NULL, combined_spanner = NULL, decimals = 0, source_note = NULL, append_note = FALSE, drop_geometry = TRUE, hide_na_cols = TRUE, currency_value = FALSE, survey = "acs5", year = 2022, table = NULL, prefix = "Source: ", end = ".", est_cols = NULL, perc_cols = NULL )
gt_acs( data, rownames_to_stub = FALSE, row_group_as_column = FALSE, ..., value_col = "estimate", moe_col = "moe", perc_prefix = "perc", perc_sep = "_", perc = FALSE, column_title_col = "column_title", name_col = "NAME", perc_value_label = "% share", value_label = "Est.", column_title_label = NULL, name_label = NULL, est_spanner = NULL, perc_spanner = NULL, combined_spanner = NULL, decimals = 0, source_note = NULL, append_note = FALSE, drop_geometry = TRUE, hide_na_cols = TRUE, currency_value = FALSE, survey = "acs5", year = 2022, table = NULL, prefix = "Source: ", end = ".", est_cols = NULL, perc_cols = NULL )
data |
Input data table
A |
rownames_to_stub |
Use data frame row labels in the stub
An option to take rownames from the input |
row_group_as_column |
Mode for displaying row group labels in the stub
An option that alters the display of row group labels. By default this is
|
... |
Additional parameters passed to |
value_col |
Column name for estimate value column. Defaults to "estimate". |
moe_col |
Column name for margin of error column. Defaults to "moe". |
perc_prefix |
Prefix string for percent value columns. |
perc_sep |
Separator string between |
perc |
If |
column_title_col , column_title_label
|
Column title and label. If
|
name_col , name_label
|
Place name column and label. |
perc_value_label |
Percent value column label. |
value_label |
Value column label. Defaults to "Est.". |
est_spanner , perc_spanner
|
Spanner labels for estimate and percent estimate columns. |
combined_spanner |
If not |
decimals |
Number of decimal places
This corresponds to the exact number of decimal places to use. A value
such as |
source_note |
Source note text
Text to be used in the source note. We can optionally use |
append_note |
If |
drop_geometry |
If |
hide_na_cols |
If |
currency_value |
If |
survey |
ACS survey, "acs5", "acs3", or "acs1". |
year |
Based on the year and survey, |
table |
One or more table IDs to include in label or source note. |
prefix |
Text to insert before ACS survey label. |
end |
A character string appended to the end of the full label. Defaults to ".". |
est_cols , perc_cols
|
Deprecated. Estimate and percent estimate columns. |
Other gt table:
fmt_acs_estimate()
,
gt_acs_compare()
,
tab_acs_source_note()
## Not run: if (interactive()) { data <- get_acs_tables( geography = "county", county = "Baltimore city", state = "MD", table = "B08134" ) tbl_data <- filter_acs(data, indent == 1, line_number <= 10) tbl_data <- select_acs(tbl_data) gt_acs( tbl_data, column_title_label = "Commute time", table = "B08134" ) } ## End(Not run)
## Not run: if (interactive()) { data <- get_acs_tables( geography = "county", county = "Baltimore city", state = "MD", table = "B08134" ) tbl_data <- filter_acs(data, indent == 1, line_number <= 10) tbl_data <- select_acs(tbl_data) gt_acs( tbl_data, column_title_label = "Commute time", table = "B08134" ) } ## End(Not run)
gt_acs_compare()
is a variant of gt_acs()
that uses pivot_acs_wider()
to support comparisons of multiple named areas or multiple geographies
side-by-side in a combined gt table.
gt_acs_compare( data, name_col = "NAME", value_col = "estimate", moe_col = "moe", perc_prefix = "perc", perc_sep = "_", perc = TRUE, variable_col = "variable", column_title_col = "column_title", value_label = "Est.", moe_label = "MOE", perc_value_label = "% share", perc_moe_label = "% MOE", column_title_label = NULL, id_cols = column_title_col, id_expand = FALSE, names_from = name_col, values_from = NULL, names_vary = "slowest", names_glue = NULL, names_sep = "_", decimals = 0, currency_value = FALSE, merge_moe = TRUE, split = "last", limit = 1, reverse = TRUE, source_note = NULL, append_note = FALSE, hide_na_cols = TRUE, survey = "acs5", year = 2022, table = NULL, prefix = "Source: ", end = ".", use_md = FALSE, use_spanner = TRUE, ... ) gt_acs_compare_vars( data, name_col = "NAME", value_col = "estimate", moe_col = "moe", perc_prefix = "perc", perc_sep = "_", variable_col = "variable", column_title_col = "column_title", value_label = NULL, moe_label = "MOE", id_cols = name_col, names_from = variable_col, values_from = c(value_col, moe_col), use_spanner = FALSE, ... )
gt_acs_compare( data, name_col = "NAME", value_col = "estimate", moe_col = "moe", perc_prefix = "perc", perc_sep = "_", perc = TRUE, variable_col = "variable", column_title_col = "column_title", value_label = "Est.", moe_label = "MOE", perc_value_label = "% share", perc_moe_label = "% MOE", column_title_label = NULL, id_cols = column_title_col, id_expand = FALSE, names_from = name_col, values_from = NULL, names_vary = "slowest", names_glue = NULL, names_sep = "_", decimals = 0, currency_value = FALSE, merge_moe = TRUE, split = "last", limit = 1, reverse = TRUE, source_note = NULL, append_note = FALSE, hide_na_cols = TRUE, survey = "acs5", year = 2022, table = NULL, prefix = "Source: ", end = ".", use_md = FALSE, use_spanner = TRUE, ... ) gt_acs_compare_vars( data, name_col = "NAME", value_col = "estimate", moe_col = "moe", perc_prefix = "perc", perc_sep = "_", variable_col = "variable", column_title_col = "column_title", value_label = NULL, moe_label = "MOE", id_cols = name_col, names_from = variable_col, values_from = c(value_col, moe_col), use_spanner = FALSE, ... )
data |
A data frame to pivot. |
name_col |
Name column. Defaults to "NAME". Ignored if names_from is not set to name_col. |
value_col |
Column name for estimate value column. Defaults to "estimate". |
moe_col |
Column name for margin of error column. Defaults to "moe". |
perc_prefix |
Prefix string for percent value columns. |
perc_sep |
Separator string between |
perc |
If |
variable_col |
Variable column name. Defaults to "variable". |
column_title_col , column_title_label
|
Column title column name and
label. Defaults to "column_title" and |
value_label |
Value column label. Defaults to "Est.". |
moe_label |
Margin of error column label. Defaults to "MOE". |
perc_value_label |
Percent value column label. |
perc_moe_label |
Percent margin of error column label. |
id_cols |
Defaults to |
id_expand |
Should the values in the |
names_from , values_from
|
< If |
names_vary |
When
|
names_glue |
Instead of |
names_sep |
If |
decimals |
Number of decimal places
This corresponds to the exact number of decimal places to use. A value
such as |
currency_value |
If |
merge_moe |
If |
split |
Splitting side
Should the delimiter splitting occur from the |
limit |
Limit for splitting
An optional limit to place on the splitting procedure. The default |
reverse |
Reverse vector of split names
Should the order of split names be reversed? By default, this is |
source_note |
Source note text
Text to be used in the source note. We can optionally use |
append_note |
If |
hide_na_cols |
If |
survey |
ACS survey, "acs5", "acs3", or "acs1". |
year |
Based on the year and survey, |
table |
One or more table IDs to include in label or source note. |
prefix |
Text to insert before ACS survey label. |
end |
A character string appended to the end of the full label. Defaults to ".". |
use_md |
If |
use_spanner |
If |
... |
Additional arguments passed on to methods. |
Other gt table:
fmt_acs_estimate()
,
gt_acs()
,
tab_acs_source_note()
Reference table of ACS "jam values" for medians from "Table 5.2. Jam Values
for Medians," Understanding and Using American Community Survey Data: What All Data Users Need to Know
(2020). type
and units
values are added. year
is included to account
for the possibility of alternate jam values for earlier or later years but
annual variation in values has not been checked.
jam_values
jam_values
A data frame with 20 rows and 6 variables:
value
Estimate value
meaning
Meaning of estimate value
use
Subjects/tables where jam value is used
type
Type (minimum or maximum jam value)
units
Units. Note year is for a specific year, years is for duration.
year
Year applicable
https://docs.google.com/spreadsheets/d/1YX3NBDkkoDXHs88KDfPS_QoS9-1j_C_q8UAyjPznfzA/edit?usp=sharing
Note that this function and the related join_acs_percent()
function depends
on the column-level metadata supplied by label_acs_metadata()
.
join_acs_denominator( data, geoid_col = "GEOID", value_col = "estimate", moe_col = "moe", column_id_col = "column_id", column_title_col = "column_title", denominator_col = NULL, denominator_prefix = "denominator_", na_matches = "never", digits = 2, call = caller_env() )
join_acs_denominator( data, geoid_col = "GEOID", value_col = "estimate", moe_col = "moe", column_id_col = "column_id", column_title_col = "column_title", denominator_col = NULL, denominator_prefix = "denominator_", na_matches = "never", digits = 2, call = caller_env() )
data |
A data frame with column names including "column_id", "column_title", "denominator_column_id", "estimate", and "moe". |
geoid_col |
A GeoID column name to use if perc is |
value_col |
Value column name |
moe_col |
Margin of error column name |
column_id_col |
Column ID column name from Census Reporter metadata. Defaults to "column_id" |
column_title_col |
Column title column name. Defaults to "column_title". |
denominator_col |
Denominator column ID name from Census Reporter
metadata. Defaults to |
denominator_prefix |
Prefix to use for denominator column names. |
na_matches |
Should two |
digits |
integer indicating the number of decimal places
( |
call |
The execution environment of a currently
running function, e.g. |
join_acs_geography_ratio()
uses data from get_acs_geographies()
to
support the calculation of proportions join parent column titles to a data
frame of ACS data.
join_acs_geography_ratio( data, variable_col = "variable", value_col = "estimate", moe_col = "moe", geography = "county", na_matches = "never", digits = 2 )
join_acs_geography_ratio( data, variable_col = "variable", value_col = "estimate", moe_col = "moe", geography = "county", na_matches = "never", digits = 2 )
data |
A data frame with column names matching the supplied parameters. |
variable_col |
Variable column name to join as join variable, Default: 'variable' |
value_col , moe_col
|
Estimate and margin of error column names, Default: 'estimate' and 'moe' |
geography |
Value in geography column to use as comparison values, Default: 'county' |
na_matches |
Should two |
digits |
integer indicating the number of decimal places
( |
A data frame with new estimate and moe columns prefixed with "ratio_".
join_acs_parent_column()
uses data labelled with parent_column_id values to
join parent column titles to a data frame of ACS data.
join_acs_parent_column( data, column_id_col = "column_id", column_title_col = "column_title", parent_id_col = "parent_column_id", suffix = c("", "_parent"), na_matches = "never", relationship = "many-to-one" )
join_acs_parent_column( data, column_id_col = "column_id", column_title_col = "column_title", parent_id_col = "parent_column_id", suffix = c("", "_parent"), na_matches = "never", relationship = "many-to-one" )
data |
A data frame with the specified column names. Expected to be
labelled using |
column_id_col , column_title_col , parent_id_col
|
Column ID, column title, and parent column ID. |
suffix |
Suffix passed to |
na_matches |
Should two |
relationship |
Handling of the expected relationship between the keys of
|
A data frame with added parent column title.
join_acs_percent()
uses the denominator_column_id value from the column
metadata added with label_acs_metadata()
to calculate the estimate as a
percent share of the denominator value. tidycensus::moe_prop()
is used to
calculate the margin of error for the percentage. join_acs_percent_parent()
is a variation that, by default, calculates the percentage values based on
the "parent_column_id"
instead of the "denomination_column_id"
.
join_acs_percent( data, geoid_col = "GEOID", column_id_col = "column_id", denominator_col = NULL, denominator_prefix = "denominator_", value_col = "estimate", moe_col = "moe", perc = TRUE, perc_prefix = "perc", perc_sep = "_", na_matches = "never", digits = 2 ) join_acs_percent_parent( data, geoid_col = "GEOID", column_id_col = "column_id", denominator_col = NULL, denominator_prefix = "parent_", value_col = "estimate", moe_col = "moe", perc_prefix = "perc_parent", perc_sep = "_", na_matches = "never", digits = 2 )
join_acs_percent( data, geoid_col = "GEOID", column_id_col = "column_id", denominator_col = NULL, denominator_prefix = "denominator_", value_col = "estimate", moe_col = "moe", perc = TRUE, perc_prefix = "perc", perc_sep = "_", na_matches = "never", digits = 2 ) join_acs_percent_parent( data, geoid_col = "GEOID", column_id_col = "column_id", denominator_col = NULL, denominator_prefix = "parent_", value_col = "estimate", moe_col = "moe", perc_prefix = "perc_parent", perc_sep = "_", na_matches = "never", digits = 2 )
data |
A data frame with column names including "column_id", "column_title", "denominator_column_id", "estimate", and "moe". |
geoid_col |
A GeoID column name to use if perc is |
column_id_col |
Column ID column name from Census Reporter metadata. Defaults to "column_id" |
denominator_col |
Denominator column ID name from Census Reporter
metadata. Defaults to |
denominator_prefix |
Prefix to use for denominator column names. |
value_col |
Value column name |
moe_col |
Margin of error column name |
perc |
If |
perc_prefix |
Prefix string for percent value columns. |
perc_sep |
Separator string between |
na_matches |
Should two |
digits |
integer indicating the number of decimal places
( |
tidycensus::moe_prop()
, camiller::calc_shares()
labs_acs_survey()
uses acs_survey_label_table()
to create a label for a
ggplot2 plot passed to the caption parameter of ggplot2::labs()
.
labs_acs_survey( ..., caption = NULL, survey = "acs5", year = 2022, prefix = "Source: ", table = NULL, .data = NULL )
labs_acs_survey( ..., caption = NULL, survey = "acs5", year = 2022, prefix = "Source: ", table = NULL, .data = NULL )
... |
Arguments passed on to
|
caption |
The text for the caption which will be displayed in the bottom-right of the plot by default. |
survey |
ACS survey, "acs5", "acs3", or "acs1". |
year |
Based on the year and survey, |
prefix |
Text to insert before ACS survey label. |
table |
One or more table IDs to include in label or source note. |
.data |
Optional data frame with "table_id" column used in place of
|
tidycensus::load_variables()
load_acs_vars()
calls tidycensus::load_variables()
and then combines the
returned data frame with the Census Reporter metadata from
label_acs_table_metadata()
. The function can optionally filter the variable
definitions to a set of tables and variables or drop variables from the
results.
load_acs_vars( year = 2022, survey = "acs5", cache = TRUE, variable_col = "variable", geography_levels = c("block", "block group", "tract", "county", "state", "us"), table = NULL, vars = NULL, drop_vars = NULL )
load_acs_vars( year = 2022, survey = "acs5", cache = TRUE, variable_col = "variable", geography_levels = c("block", "block group", "tract", "county", "state", "us"), table = NULL, vars = NULL, drop_vars = NULL )
year |
Sample year (between 2006 and 2022). |
survey |
Survey, "acs5", "acs3", or "acs1". |
cache |
Whether you would like to cache the dataset for future access, or load the dataset from an existing cache. Defaults to FALSE. |
variable_col |
Variable column name. Defaults to "variable" |
geography_levels |
Ordered vector of geography levels used to convert
the geography column returned by |
table |
Table ID to return. |
vars , drop_vars
|
Variable IDs to keep or to drop. If table is supplied (or if data only contains data for a single table), numeric values are allowed for vars and drop_vars (e.g. if table is "B14001" and vars is 2 data is filtered to variable "B14001_002"). |
A data frame with ACS variables definitions.
make_area_xwalk()
creates a crosswalk data frame based on the weight_col
parameter (if year = 2020
, use "POP20" for population, "HOUSING20" for
households, or "ALAND20" for land area). Using this function with other
years, requires users to add population data to the block_xwalk as the
tigris::blocks()
function only includes population and household count data
for the 2020 year. This function has also not been tested when areas include
overlapping geometry and the results may be invalid for those overlapping
areas if that is the case.
make_area_xwalk( area, block_xwalk = NULL, state = NULL, county = NULL, year = 2020, name_col = "NAME", weight_col = "HOUSING20", geoid_col = "GEOID", tract_col = "TRACTCE20", by = c(TRACTCE20 = "TRACTCE"), suffix = c("_block", "_tract"), placement = c("largest", "surface", "centroid"), digits = 2, extensive = TRUE, coverage = TRUE, erase = FALSE, area_threshold = 0.75, keep_geometry = FALSE, crs = NULL, make_valid = TRUE, ... ) use_area_xwalk( data, area_xwalk, geography = "area", name_col = "NAME", geoid_col = "GEOID", suffix = c("_area", ""), weight_col = "perc_HOUSING20", variable_col = "variable", value_col = "estimate", moe_col = "moe", digits = 0, perc = TRUE, extensive = TRUE, reliability = FALSE, moe_level = 90 )
make_area_xwalk( area, block_xwalk = NULL, state = NULL, county = NULL, year = 2020, name_col = "NAME", weight_col = "HOUSING20", geoid_col = "GEOID", tract_col = "TRACTCE20", by = c(TRACTCE20 = "TRACTCE"), suffix = c("_block", "_tract"), placement = c("largest", "surface", "centroid"), digits = 2, extensive = TRUE, coverage = TRUE, erase = FALSE, area_threshold = 0.75, keep_geometry = FALSE, crs = NULL, make_valid = TRUE, ... ) use_area_xwalk( data, area_xwalk, geography = "area", name_col = "NAME", geoid_col = "GEOID", suffix = c("_area", ""), weight_col = "perc_HOUSING20", variable_col = "variable", value_col = "estimate", moe_col = "moe", digits = 0, perc = TRUE, extensive = TRUE, reliability = FALSE, moe_level = 90 )
area |
A sf object with an arbitrary geography overlapping with the
block_xwalk. Required. If area only partly overlaps with block_xwalk,
coverage should be set to |
block_xwalk |
Block-tract crosswalk sf object. If |
state |
The two-digit FIPS code (string) of the state you want. Can also be state name or state abbreviation. |
county |
The three-digit FIPS code (string) of the county you'd like to subset for, or a vector of FIPS codes if you desire multiple counties. Can also be a county name or vector of names. |
year |
the data year; defaults to 2022 |
name_col |
Name column in area. |
weight_col |
Column name in input block_xwalk to use for weighting.
Generated weight_col used by |
geoid_col , tract_col
|
GeoID for Census tract and Census tract ID column in block_xwalk |
by |
Specification of join variables in the format of c("block column
name for tract" = "tract column name"). Passed to |
suffix |
Suffixes added to the output to disambiguate column names from the block and tract data. Unused for 2020 data. |
placement |
String with option for joining |
digits |
Digits to use for percent share of weight value. |
extensive |
If |
coverage |
If |
erase |
If |
area_threshold |
The percentile rank cutoff of water areas to use in the erase operation, ranked by size. Defaults to 0.75, representing the water areas in the 75th percentile and up (the largest 25 percent of areas). This value may need to be modified by the user to achieve optimal results for a given location. |
keep_geometry |
If |
crs |
Coordinate reference system to use for input data. Recommended to set to a projected CRS if input area data is in a geographic CRS. |
make_valid |
Default |
... |
Passed to |
data |
A data frame downloaded with |
area_xwalk |
A area crosswalk data frame created with
|
geography |
A character string used as general description for area geography type. Defaults to "area" but typical values could include "neighborhood", "planning district", or "service area". |
variable_col |
Variable column name. Defaults to "variable" |
value_col , moe_col
|
Value and margin of error column names (defaults to "estimate" and "moe"). |
perc |
If |
reliability |
If |
moe_level |
The confidence level of the margin of error. Defaults to 90
(which is the same default as |
Using an area crosswalk
After creating an area crosswalk with make_area_xwalk()
, you can pass the
crosswalk to use_area_xwalk()
along with a data frame from
tidycensus::get_acs()
or get_acs_tables()
. At a minimum, the data must
have a column with the same name as geoid_col along with columns named
"variable", "estimate", and "moe".
Please note that this approach to aggregation does not work well if your data contains "jam" values, e.g. the substitution of 0 for "1939 or older" for the Median Year Built variable. Ideally, the weight used for aggregation should be based on household counts when aggregating a household-level variable and population counts when aggregating a individual-level variable.
A tibble or a sf object.
tidycensus::interpolate_pw()
, areal::aw_interpolate()
make_block_xwalk()
joined U.S. Census blocks data from tigris::blocks()
to a data frame from tigris::tracts()
to provide a crosswalk between both
geographies. If year = 2020
, the suffix parameter is not used. If year is
any other year than 2020, the by parameter must be changed from the default
value of c("TRACTCE20" = "TRACTCE")
. 2020 is also the only year where
tigris::blocks()
includes the population and household count data required
to use this crosswalk data frame with make_area_xwalk()
.
make_block_xwalk( state, county = NULL, year = 2020, by = c(TRACTCE20 = "TRACTCE"), keep_zipped_shapefile = TRUE, suffix = c("_block", "_tract"), crs = NULL, ... )
make_block_xwalk( state, county = NULL, year = 2020, by = c(TRACTCE20 = "TRACTCE"), keep_zipped_shapefile = TRUE, suffix = c("_block", "_tract"), crs = NULL, ... )
state |
The two-digit FIPS code (string) of the state you want. Can also be state name or state abbreviation. |
county |
The three-digit FIPS code (string) of the county you'd like to subset for, or a vector of FIPS codes if you desire multiple counties. Can also be a county name or vector of names. |
year |
the data year; defaults to 2022 |
by |
Specification of join variables in the format of c("block column
name for tract" = "tract column name"). Passed to |
keep_zipped_shapefile |
Passed to |
suffix |
Suffixes added to the output to disambiguate column names from the block and tract data. Unused for 2020 data. |
crs |
Coordinate reference system to return. |
... |
Arguments passed on to |
pivot_acs_wider()
wraps tidyr::pivot_wider()
and makes it easy to convert
an ACS data frame into a wide format by changing the value of the
names_from
parameter. The default parameter value vary from the tidyr
version with names_vary = "slowest"
and values_from = NULL
(replaced by
using the .col_fn
{tidyselect}
function on the named value and percent
value columns). You may need to retain the variable column and set id_cols = "variable"
if the column_title does not uniquely identify rows after
widening the input data.
pivot_acs_wider( data, name_col = "NAME", value_col = "estimate", moe_col = "moe", perc_prefix = "perc", perc_sep = "_", perc = TRUE, .col_fn = any_of, ..., id_cols = NULL, id_expand = FALSE, names_from = name_col, names_sep = "_", names_glue = NULL, names_vary = "slowest", names_repair = "check_unique", values_from = NULL )
pivot_acs_wider( data, name_col = "NAME", value_col = "estimate", moe_col = "moe", perc_prefix = "perc", perc_sep = "_", perc = TRUE, .col_fn = any_of, ..., id_cols = NULL, id_expand = FALSE, names_from = name_col, names_sep = "_", names_glue = NULL, names_vary = "slowest", names_repair = "check_unique", values_from = NULL )
data |
A data frame to pivot. |
name_col |
Name column. Defaults to "NAME". Ignored if names_from is not set to name_col. |
value_col |
Column name for estimate value column. Defaults to "estimate". |
moe_col |
Column name for margin of error column. Defaults to "moe". |
perc_prefix |
Prefix string for percent value columns. |
perc_sep |
Separator string between |
perc |
If |
.col_fn |
tidyselect function to use with column names. Defaults to tidyselect::starts_with, |
... |
Arguments passed on to
|
id_cols |
< Defaults to all columns in |
id_expand |
Should the values in the |
names_from , values_from
|
< If |
names_sep |
If |
names_glue |
Instead of |
names_vary |
When
|
names_repair |
What happens if the output has invalid column names?
The default, |
For selected tables, an alphabetic suffix follows to indicate that a table is repeated for the nine major race and Hispanic or Latino groups.
race_iteration
race_iteration
A data frame with 9 rows and 3 variables:
code
Code
group
Race or Ethnic group
label
Short label
https://www.census.gov/programs-surveys/acs/data/data-tables/table-ids-explained.html
Scales for plotting ACS data with ggplot2
scale_x_acs(..., perc = FALSE) scale_y_acs(..., perc = FALSE) scale_x_acs_estimate(name = "Estimate", ..., labels = scales::label_comma()) scale_y_acs_percent( name = "Est. % of total", ..., labels = scales::label_percent() ) scale_x_acs_percent( name = "Est. % of total", ..., labels = scales::label_percent() ) scale_y_acs_estimate(name = "Estimate", ..., labels = scales::label_comma()) scale_x_acs_ts(name = "Year", ..., breaks = NULL, survey = "acs5", year = 2022) scale_y_acs_ts(name = "Year", ..., breaks = NULL, survey = "acs5", year = 2022)
scale_x_acs(..., perc = FALSE) scale_y_acs(..., perc = FALSE) scale_x_acs_estimate(name = "Estimate", ..., labels = scales::label_comma()) scale_y_acs_percent( name = "Est. % of total", ..., labels = scales::label_percent() ) scale_x_acs_percent( name = "Est. % of total", ..., labels = scales::label_percent() ) scale_y_acs_estimate(name = "Estimate", ..., labels = scales::label_comma()) scale_x_acs_ts(name = "Year", ..., breaks = NULL, survey = "acs5", year = 2022) scale_y_acs_ts(name = "Year", ..., breaks = NULL, survey = "acs5", year = 2022)
... |
Other arguments passed on to |
perc |
If |
name |
The name of the scale. Used as the axis or legend title. If
|
labels |
One of:
|
breaks |
One of:
|
survey |
ACS survey, "acs5", "acs3", or "acs1". |
year |
Based on the year and survey, |
dplyr::select()
select_acs( .data, ..., .name_col = "NAME", .column_title_col = "column_title", .value_col = "estimate", .moe_col = "moe", .perc_prefix = "perc", .perc_sep = "_", .perc = TRUE, .fn = any_of )
select_acs( .data, ..., .name_col = "NAME", .column_title_col = "column_title", .value_col = "estimate", .moe_col = "moe", .perc_prefix = "perc", .perc_sep = "_", .perc = TRUE, .fn = any_of )
.data |
A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). See Methods, below, for more details. |
... |
< |
.name_col , .column_title_col , .value_col , .moe_col
|
ACS data column names
to select using the Tidyverse selection helper in |
.perc_prefix , .perc_sep
|
Percent value prefix and separator. Set
.perc_prefix to |
.perc |
If |
.fn |
Tidyverse selection helper to use with named ACS columns. Defaults
to tidyselect::any_of. See |
select_acs()
is a wrapper for dplyr::select()
designed to select the
appropriate columns for a gt table created with gt_acs()
. Set any named
parameter to NULL
to drop the respective column or use the additional ...
parameter to modify the selection.
## Not run: if (interactive()) { edu_data <- get_acs_tables( "county", table = "B15003", state = "MD", county = "Baltimore city" ) select_acs(edu_data) } ## End(Not run)
## Not run: if (interactive()) { edu_data <- get_acs_tables( "county", table = "B15003", state = "MD", county = "Baltimore city" ) select_acs(edu_data) } ## End(Not run)
tab_acs_source_note()
adds a source note to a gt table using
acs_survey_label_table()
and gt::tab_source_note()
.
tab_acs_source_note( gt_object, source_note = NULL, append_note = FALSE, survey = "acs5", year = 2022, table = NULL, table_label = "Table", prefix = "Source: ", end = ".", use_md = FALSE, ... )
tab_acs_source_note( gt_object, source_note = NULL, append_note = FALSE, survey = "acs5", year = 2022, table = NULL, table_label = "Table", prefix = "Source: ", end = ".", use_md = FALSE, ... )
gt_object |
A gt object. |
source_note |
Source note text
Text to be used in the source note. We can optionally use |
append_note |
If |
survey |
ACS survey, "acs5", "acs3", or "acs1". |
year |
Based on the year and survey, |
table |
One or more table IDs to include in label or source note. |
table_label |
Label to use when referring to table or tables. A "s" is appended to the end of the table_label if tables is more than length 1. |
prefix |
Text to insert before ACS survey label. |
end |
A character string appended to the end of the full label. Defaults to ".". |
use_md |
If |
... |
For |
Other gt table:
fmt_acs_estimate()
,
gt_acs()
,
gt_acs_compare()
Index created with esri2sf::esriIndex()
listing all services located at
https://tigerweb.geo.census.gov/arcgis/rest/services. Access ArcGIS
services using the esri2sf package https://github.com/elipousson/esri2sf or
arcpullr https://github.com/pfrater/arcpullr/.
tigerweb_geo_index
tigerweb_geo_index
A data frame with 7081 rows and 15 variables:
name
Name
type
Service/layer type
url
Folder/service/layer URL
urlType
URL type
folderPath
Index type
serviceName
Service name
serviceType
Service type
id
integer Layer ID number
parentLayerId
integer Parent layer ID number
defaultVisibility
logical Layer default visibility
subLayerIds
list Sublayer ID numbers
minScale
double Minimum scale
maxScale
integer Maximum scale
geometryType
Geometry type
supportsDynamicLegends
logical Supports dynamic legends
https://tigerweb.geo.census.gov/arcgis/rest/services
A reference table of state names, abbreviations, regions, and divisions.
usa_states
usa_states
A data frame with 56 rows and 7 variables:
state
State name
state_abb
State USPS abbreviation
STATE_GEOID
State GeoID
division
Census Division name
DIVISION_GEOID
Census Division GeoID
region
Census Region name
REGION_GEOID
Census Region GeoID
Vectorized variant of tidycensus::get_acs
vec_get_acs(..., .fn = tidycensus::get_acs, .size = NULL, .call = caller_env())
vec_get_acs(..., .fn = tidycensus::get_acs, .size = NULL, .call = caller_env())
... |
Additional parameters passed to .fn. |
.fn |
Function to call with parameters, Defaults to
|
.size |
Desired output size. |
.call |
The execution environment of a currently
running function, e.g. |
A list of data frames (using default .fn value or another function that returns a data frame).
A list of data frames.
## Not run: if (interactive()) { # TODO: Add examples } ## End(Not run)
## Not run: if (interactive()) { # TODO: Add examples } ## End(Not run)