tt_update: Update a translation table with new samples

Description Usage Arguments Note Author(s) Examples

View source: R/tt_update.R

Description

This function is designed to facilitate batch processing of translation table updates. A new_sample_updates type of config file must be provided as input. Translation tables written with this function will appear in the user's working directory: it will not overwrite translation tables in the PMA variables folder (unless that folder is used as the working directory).

Usage

1
2
3
4
5
6
7
8
tt_update(
  path_or_variable,
  config,
  univ_cases,
  dds,
  write = T,
  open_on_write = F
)

Arguments

path_or_variable

Character: Either a full path to a translation table or the variable name associated with a translation table currently in the PMA variables folder

config

A tibble object created by config_make or imported from CSV. The user may also construct a tibble object from scratch and pass it to this argument.

univ_cases

Optional: An expression using the function "case_when" or "if_else" specifying the universe logic for new samples (see vignette). If not provided, the user will have to add new samples to the <univ> block by hand in Excel.

dds

Optional: a list of Data Dictionary objects creeated by dds_list(). If not provided, dds_list will be run automatically.

write

Logical: defaults TRUE. If FALSE, the translation table will be returned as a tibble and not written.

open_on_write

Logical: defaults FALSE. If TRUE, the new translation table will be opened in Excel.

Note

Users should note that additional functions for translation tables can be accessed via py$TranslationTable() (see py). Consult ipums-metadata library documentation for a complete list of available functions.

Author(s)

Matt Gunther

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
## Not run: 
# Update a translation table in an in_progress folder
# Note: all new samples but et2019a_hh get the universe "Women age 10 to 49."
tt_update(
  "Z:/pma/variables/tt_work/Matt/in_progress/resultfq_tt.xls",
  config = read_csv("Z:/pma/admin/config_files/02-Jul-2020_17.50/new_sample_updates.csv"),
  univ_cases = case_when(
    sample == "et2019a_hh" ~ "Women age 15 to 49.",
    T ~ "Women age 10 to 49."
  ),
  dds = dds,
  write = F
 )
 
# Update a translation table in a the PMA variables folder
# Note: all new samples but et2019a_hh get the universe "Women age 10 to 49."
tt_update(
  "resultfq",
  config = read_csv("Z:/pma/admin/config_files/02-Jul-2020_17.50/new_sample_updates.csv"),
  univ_cases = case_when(
    sample == "et2019a_hh" ~ "Women age 15 to 49.",
    T ~ "Women age 10 to 49."
  ),
  dds = dds,
  write = F
 )
 

## End(Not run)

mgunther87/ipumsPMA documentation built on Aug. 1, 2020, 12:22 a.m.