knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Environment Prep

load packages

search()
library(tidyverse)
search()

check for global objects

ls()

create model population for multiple baseline_terr_cd

TRAIN <- data.frame(
  deriv_terr_cd = LETTERS[1:10], 
  opr_area_cd = paste0(LETTERS[11:20],LETTERS[20:11]),
  n = round(runif(n = 10, min = 10000, 190000))
  )

TRAIN

check for global objects again

ls()

Data Prep

declare active variables

part_by <- 'group_id'
step_nm <- 'data_prep'
out_ext <- 'sql'
step_num = 2

declare passive variables

terr_cd <- TRAIN$deriv_terr_cd
terr_cd

create one sql file using '[ ]' notation

dstrain::model_pop_sql(terr_cd = terr_cd[1], part_by = part_by
                       , step_nm = step_nm, out_ext = out_ext, step_num = step_num)

create multiple sql files using purrr

terr_cd %>% walk(~dstrain::model_pop_sql(terr_cd = .x, part_by = part_by, step_nm = step_nm, out_ext = out_ext, step_num = step_num))

"He who gives up [code] safety for [code] speed deserves neither." (via)



ahardisty/dstrain documentation built on May 28, 2019, 4:42 p.m.