get_recent_extracts_info: Get information on recent extracts

get_recent_extracts_infoR Documentation

Get information on recent extracts

Description

Get information on recent extracts for a given IPUMS collection via the IPUMS API, returned either as a list or tibble. For an overview of ipumsr API functionality, see vignette("ipums-api", package = "ipumsr").

Usage

get_recent_extracts_info_list(
  collection,
  how_many = 10,
  api_key = Sys.getenv("IPUMS_API_KEY")
)

get_recent_extracts_info_tbl(
  collection,
  how_many = 10,
  api_key = Sys.getenv("IPUMS_API_KEY")
)

Arguments

collection

The IPUMS data collection for the extract.

how_many

Number of recent extracts for which you'd like information. Defaults to 10 extracts.

api_key

API key associated with your user account. Defaults to the value of environment variable "IPUMS_API_KEY".

Value

For get_recent_extracts_info_list(), a list of ipums_extract objects. For get_recent_extracts_info_tbl(), a tbl_df with information on one extract in each row.

See Also

Other ipums_api: define_extract_from_json(), define_extract_micro(), download_extract(), extract_list_to_tbl(), extract_tbl_to_list(), get_extract_info(), get_last_extract_info(), ipums_data_collections(), is_extract_ready(), revise_extract_micro(), save_extract_as_json(), submit_extract(), wait_for_extract()

Examples

## Not run: 
# Get list of recent extracts
list_of_last_10_extracts <- get_recent_extracts_info_list("usa")

# Print the extract number for extracts that are downloadable:
for (extract in list_of_last_10_extracts) {
  if (is_extract_ready(extract)) print(extract$number)
}

# Get tibble of recent extracts
tbl_of_last_10_extracts <- get_recent_extracts_info_tbl("usa")

# Filter down to extracts with "income" in the description
description_mentions_income <- grepl(
  "[Ii]ncome",
  tbl_of_last_10_extracts$description
)
income_extracts <- tbl_of_last_10_extracts[description_mentions_income, ]

# Convert tibble of extracts to list of extracts
income_extracts <- extract_tbl_to_list(income_extracts)

# Now it's easier to operate on those elements as extract objects:
revised_income_extract <- revise_extract_micro(
  income_extracts[[1]],
  samples_to_add = "us2018a"
)

submitted_revised_income_extract <- submit_extract(revised_income_extract)

## End(Not run)


mnpopcenter/ipumsr documentation built on Sept. 30, 2022, 6:56 a.m.