list_dataset_columns: List columns available for analysis in APDE datasets

View source: R/utilities.R

list_dataset_columnsR Documentation

List columns available for analysis in APDE datasets

Description

Returns the available columns for a specified dataset. This function adapts to different data sources (SQL databases, network files) and handles various dataset-specific requirements like year validation and analytic-ready flags.

Usage

list_dataset_columns(
  dataset = NULL,
  year = 2021,
  mykey = "hhsaw",
  kingco = TRUE,
  analytic_only = FALSE
)

Arguments

dataset

Character vector of length 1. Identifies the dataset to be fetched. Use list_apde_data for available options.

year

Year(s) of dataset to check. Only applies to BRFSS, HYS, and PUMS data. For PUMS data, this is limited to a single year (e.g., 2023) or a continuous 5-year period (e.g., 2018:2022). Defaults to year = 2021.

mykey

Character vector of length 1 OR a database connection. Identifies the keyring:: key that can be used to access the Health & Human Services Analytic Workspace (HHSAW). Defaults to mykey = 'hhsaw'.

kingco

Logical. Toggle for King County (TRUE) or WA State (FALSE) column names. Only applys to BRFSS data. Defaults to kingco = TRUE.

analytic_only

Logical. Controls whether columns outside the analytic dataset should be returned. Only applies to HYS data. Defaults to analytic_only = FALSE.

Details

This function handles multiple data sources with different requirements:

  • SQL-based (birth, death, chars): Accessed via HHSAW

  • Network-based (BRFSS, HYS, PUMS): Need appropriate permissions

Network paths required:

  • BRFSS (kingco = T): '//dphcifs/APDE-CDIP/BRFSS/prog_all/final_analytic.rds'

  • BRFSS (kingco = F): '//dphcifs/APDE-CDIP/BRFSS/WA/wa_final_analytic.rds'

  • HYS: '//dphcifs/APDE-CDIP/HYS/releases/2021/best/hys_cols.csv'

  • PUMS: '//dphcifs/APDE-CDIP/ACS/PUMS_data/' and subdirectories

Value

A data.table with dataset-specific columns:

  • All datasets: 'var.names' (variable names)

  • BRFSS/HYS/PUMS: Additional 'year(s)' column

  • HYS only: 'analytic_ready' flag

  • PUMS only: 'records' indicating household/person level

Examples


 # SQL-based data
 list_dataset_columns('birth')
 list_dataset_columns('chars', mykey = 'hhsaw')
 list_dataset_columns('death', mykey = 'hhsaw')

 # Network-based data
 list_dataset_columns('hys', year = 2021, analytic_only = TRUE)
 list_dataset_columns('brfss', year = 2014:2023)
 list_dataset_columns('pums', year = 2018:2022)


PHSKC-APDE/rads documentation built on April 14, 2025, 10:47 a.m.