get_vintage_data: get_vintage_data()

View source: R/get_vintage_data.R

get_vintage_dataR Documentation

get_vintage_data()

Description

Function produces a data.table/dataframe of Census Bureau data. The function requires an access key issued from the Bureau.

Usage

get_vintage_data(
  dataset,
  vintage = NULL,
  vars,
  vars_init = c("GEO_ID", "NAME"),
  group = NULL,
  group_values = c("estimate", "moe"),
  region = NULL,
  regionin = NULL,
  na_cols = NULL,
  shape = "long",
  melt_meas = NULL,
  melt_values = NULL,
  key = Sys.getenv("CENSUS_KEY")
)

Arguments

dataset

A string that sets the name of the data set of interest (e.g. "acs/acs5")

vintage

An optional numeric that sets the vintage of interest.

vars

Can be either a string vector of variable names to be acquired. Also can be a named list of string vectors to separate groups of variables.

vars_init

A string vector of variable names to append to vars, The default is c("GEO_ID", "NAME"). Set it to NULL to disregard it.

group

A string that names the group that has a collection of variables. A dataframe is returned in the "long" format with a factor column named "variables" with their respective values.

group_values

A string vector that sets the type of output values. Permissible values are "estimate" (for estimates) "moe" (for margin of error). The default is c("estimate", "moe") for both.

region

A string that specifies the geography of the request. See Rcensus::get_geography() for assistance in obtaining these values.

regionin

A string that sets a qualifier for region.

na_cols

If TRUE will remove all rows with missing values. If a vector of column names/integers will check their values for missing values.

shape

A string that sets the shape of the returned dataframe. Permissible values are "long" (the default) or "wide".

melt_meas

A list that contains character vectors of column names/indexes from dataset to be consolidated. It is the measure.vars argument in data.table's wide-to-long melt reshaping tool.

melt_values

A Vector that assigns a value to each of the consolidated columns.

key

A key string issued by the Census Bureau in making data requests.

Details

Get Census Bureau data for a specific dataset, variables, and region in the form of a dataframe.

Value

A data.table

Author(s)

Rick Dean


deandevl/Rcensus documentation built on Aug. 9, 2022, 8:24 p.m.