This tutorial contains the functions the team used to explore and prepare the Longitudinal Tracts Database files used as the raw data source for this project. The “helper_function.R” file can be found in the “analysis” folder in the repository.

# load necessary functions and objects ----
library( here )
library(data.table)
library( dplyr )
library( pander )
library( tidyverse )
library( readr )
library(forecast)
library(knitr)
# store data dictionary file path
DD_FILEPATH <- here::here( "data/rodeo/ltdb_data_dictionary.csv" )

# import data dictionary
dd <- read.csv( DD_FILEPATH, stringsAsFactors=F )
# load functions source files
source(here("labs/wk02/helper_function.R"))

Run functions

Filter variables by theme or group

filter_data(dd, "ethnicity")

Create a function that searches variable descriptions for a specific string

keyword_search(dd, "persons")

Create a function to filter variables by time periods

variable_years(dd, c("1990", "2000", "2010" ))
variables <- variable_years(dd, c("1990", "2000", "2010"))

variables %>% distinct(root)
left_join(variables, dd) %>% tail(50)
## Joining, by = "root"