set_ipums_default_collection {ipumsr} | R Documentation |
Set your default IPUMS collection
Description
Set the default IPUMS collection as the value associated with the
IPUMS_DEFAULT_COLLECTION
environment variable. If this environment variable
exists, IPUMS API functions that require a collection specification will use
the value of IPUMS_DEFAULT_COLLECTION
, unless another collection is
indicated.
The default collection can be stored for the duration of your session or
for future sessions. If saved for future sessions, it is added to the
.Renviron
file in your home directory. If you choose to save your key
to .Renviron
, this function will create a backup copy of the file before
modifying.
This function is modeled after the census_api_key()
function
from tidycensus.
Learn more about the IPUMS API in vignette("ipums-api")
.
Usage
set_ipums_default_collection(
collection = NULL,
save = overwrite,
overwrite = FALSE,
unset = FALSE
)
Arguments
collection |
Character string of the collection to set as your default collection. The collection must currently be supported by the IPUMS API. For a list of codes used to refer to each collection, see
|
save |
If |
overwrite |
If |
unset |
if |
Value
The value of collection
, invisibly.
See Also
set_ipums_api_key()
to set an API key.
Examples
set_ipums_default_collection("nhgis")
## Not run:
# Extract info will now be retrieved for the default collection:
get_last_extract_info()
get_extract_history()
is_extract_ready(1)
get_extract_info(1)
# Equivalent to:
get_extract_info("nhgis:1")
get_extract_info(c("nhgis", 1))
# Other collections can be specified explicitly
# Doing so does not alter the default collection
is_extract_ready("usa:2")
## End(Not run)
# Remove the variable from the environment and .Renviron, if saved
set_ipums_default_collection(unset = TRUE)