Skip to contents

Return a list of variable names or data frame of variable metadata containing a given string. This can be used create a list of variables to later pass to getCensus, or a data frame documenting variables used in a given project.

Usage

makeVarlist(name, vintage = NULL, find, varsearch = "all", output = "list")

Arguments

name

API programmatic name - e.g. acs/acs5. Use listCensusApis() to see valid dataset names.

vintage

Vintage (year) of dataset. Not required for timeseries APIs.

find

A string to find in the variable metadata.

varsearch

Optional argument specifying which fields to search. Default is "all". Options are "all", "name", "label", or "concept".

output

Optional argument, specifying output to "list" or "dataframe". Default is "list".

Value

A data frame containing variable metadata

See also

Other metadata: listCensusApis(), listCensusMetadata()

Examples

# Return a list, and then use getCensus function to retrieve those variables
myvars <- makeVarlist(name = "timeseries/poverty/saipe",
  find = "Ages 0-4",
  varsearch = "label")
myvars
#> [1] "SAEPOVRT0_4_UB90" "SAEPOVRT0_4_MOE"  "SAEPOVRT0_4_LB90" "SAEPOVRT0_4_PT"  
#> [5] "SAEPOV0_4_PT"     "SAEPOVU_0_4"      "SAEPOV0_4_MOE"    "SAEPOV0_4_UB90"  
#> [9] "SAEPOV0_4_LB90"  
saipe_dt <- getCensus(name = "timeseries/poverty/saipe",
  time = 2016,
  vars = myvars,
  region = "state:*")
head(saipe_dt)
#>   time state SAEPOVRT0_4_UB90 SAEPOVRT0_4_MOE SAEPOVRT0_4_LB90 SAEPOVRT0_4_PT
#> 1 2016    01             28.9             1.5             25.9           27.4
#> 2 2016    02             17.0             1.9             13.2           15.1
#> 3 2016    04             26.1             1.2             23.7           24.9
#> 4 2016    05             29.1             1.8             25.5           27.3
#> 5 2016    06             21.2             0.5             20.2           20.7
#> 6 2016    08             15.1             1.2             12.7           13.9
#>   SAEPOV0_4_PT SAEPOVU_0_4 SAEPOV0_4_MOE SAEPOV0_4_UB90 SAEPOV0_4_LB90
#> 1        78675      287177          4418          83093          74257
#> 2         7919       52408          1021           8940           6898
#> 3       106817      428317          5131         111948         101686
#> 4        50341      184115          3246          53587          47095
#> 5       502432     2430975         13017         515449         489415
#> 6        46111      330815          3894          50005          42217