desc_make: Create variable description files from a template

Description Usage Arguments Details Note Author(s)

View source: R/desc_make.R

Description

This function is designed to facilitate batch processing of variable description files from a template. See article for details on template, and for an explanation of how function arguments replace its all-caps text. Non-caps text cannot be overwritten.

Output for mac users will be finished .doc files, while windows users will produce .txt files that must be manually saved as .doc.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
desc_make(
  TTpath_or_variable,
  INDICATED = "INDICATED",
  CONDITION = "",
  SURVEY = "SURVEY",
  COMMENT,
  COMPARABILITY,
  MANUAL_IND,
  write = T,
  open_on_write = F
)

Arguments

TTpath_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

INDICATED

Character string to be substituted for INDICATED in the template (see example).

CONDITION

Character string to be substituted for CONDITION in the template (see example).

SURVEY

Character string to be substituted for SURVEY in the template (see example).

COMMENT

Optional: character string to be inserted in the comment section of the template.

COMPARABILITY

Optional: character string to replace the text in the comparability section of the template.

MANUAL_IND

Optional: character string to replace INDICATED in the MANUALCODES section. Note that a MANUALCODES section is automatically generated for variables where the associated translation table has been marked as a partial recode. This includes the template sentence "This is a WIDTH-digit variable representing INDICATED, except for the following codes:", whereby WIDTH is automatically calculated, and INDICATED is a copy of the text provided by the user in INDICATED if MANUAL_IND is not otherwise specified.

write

Logical: defaults TRUE, so a text file will be written (overwriting any file in the folder sharing the same name). FALSE may be used to simply preview the text to be written (this preview will be generated if TRUE as well)

open_on_write

Logical: defaults FALSE. If TRUE, the document will open in Word (or default .txt writer).

Details

A MANUALCODES section will be completed automatically if any of the samples in an accomanying translation table holds the value 2 in its "norecode" row. Output codes and values will be copied from the translation table and written in the new description file.

Note

This function is particularly useful if included in a loop, where the substituted text is drawn from (for instance) the variable tracking sheet via tracking_get. See article for detailed instructions.

Author(s)

Matt Gunther


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