getCensus()
no longer requires key
, the use of a Census Bureau API key. Users are still encouraged to register for and use an API key because the Census Bureau may rate limit IP addresses, but it is not required. (#87)get_api_key()
helper function retrieves the value of a user's stored Census Bureau API key from a saved environment variable or provides a warning message if none is found.has_api_key()
helper function detects if there is a stored Census Bureau API key in the Renviron, intended mainly for internal use.getCensus()
uses improved logic to automatically convert columns that contain all numbers to numeric, unless the column name is in a specific list of geography names or other string type columns. Use convert_variables = FALSE
to leave all columns as characters.listCensusApis()
now has optional name
and vintage
parameters to get metadata for a subset of datasets or a single dataset. (#103)# Get metadata for all 2020 Decennial Census datasets
apis_decennial_2020 <- listCensusApis(name = "dec", vintage = 2020)
# Get metadata for all timeseries datasets
apis_timeseries <- listCensusApis(name = "timeseries")
listCensusApis()
has new columns in the resulting data frame of available API endpoints: the API contact
email address and type
: either Aggregate, Timeseries, or Microdata.
listCensusMetadata()
has new functionality to use value
metadata. This is particularly useful for some of the economic datasets and the microdata APIs.
Use type = "variables"
and include_values = TRUE
to create a dictionary with all value labels for a given dataset.
To get value labels for a single variable in a given dataset, use type = "values"
and variable = "VARIABLE OF INTEREST"
.
Note: This metadata, while incredibly useful, only exists for some datasets. For other datasets you'll still need to reference external files until the Census Bureau adds this functionality.
For example, get the value labels for the NAICS2017
in the County Business Patterns dataset:
cbp_naics_values <- listCensusMetadata(
name = "cbp",
vintage = 2020,
type = "values",
variable = "NAICS2017")
Or make a full dictionary for the Current Population Survey Voting Patterns microdata API:
cbp_dict <- listCensusMetadata(
name = "cbp",
vintage = 2020,
type = "variables",
include_values = TRUE)
getCensus()
has a new option convert_variables
re discussion in (#68) and (#80). The default is TRUE
— as in previous versions, this converts columns of numbers to R's numeric data type. Setting convert variables = FALSE
leaves all columns in the original character data type returned by the Census Bureau.
getCensus()
has improved data binding for responses from requests where more than 50 variables are manually specified. Occasionally these large requests were not returned from the Census Bureau in the same order, leading to mismatched rows. This fixes (#82).
listCensusMetadata()
now properly handles metadata attribute names in the new Microdata APIs that contain invalid JSON. This fixes (#84).
Documentation and examples are updated. There is a new vignette: Accessing microdata.
YEAR
to getCensus()
per changes to some timeseries endpoints that previously used TIME
as a parameter.listCensusMetadata()
and masterlist examples that used Business Dynamic Statistics endpoints, which were recently deprecated.show_call
option to getCensus()
, which shows the underlying API call (otherwise only shown on errors) and link to package documentation when used.getCensus()
. This allows users to specify any valid API argument name and pass it a value, giving full access to all of the underlying Census Bureau APIs.group
parameter in listCensusMetadata()
. This allows users to get variable metadata for a specified variable group.listCensusMetadata()
.region
an optional argument in getCensus
, rather than required.fips
dataset with zeroes.groups
type option to listCensusMetadata
.listCensusMetadata
variables call caused by an underlying Census API change, which renamed validValues
to values
for some endpoints.dec/sf1
endpoint, which will replace 2010 sf1
endpoint on August 30, 2018.listCensusMetadata
variables call caused by underlying Census API changes.listCensusMetadata
. For most APIs, this function will run in under one second. A lag may be noticeable for the American Community Survey APIs, which each have more than 40,000 variables. Improvements are planned in future releases.listCensusMetadata
allows full word or single letter argument in type
parameterlistCensusApis
, in starts of removing XML dependency. The .json data also includes several fields not present in the .html file, the most useful of which are added to the returned data frame.listCensusMetadata
examples, mainly for build/checks speed.getCensus(key)
argument's default value to be CENSUS_KEY in .Renviron. Explicitly encourages Census key to be added to .Renviron. (Users can always override this with any given input.)