make_dua_template: Interactive function to create template file

Description Usage Arguments Details Examples

View source: R/template.R

Description

Use this function to create a template script that puts package functions in order and, based on question answers, prepopulates some arguments. By default, this function is run in interactive mode, meaning that it will not work in a script unless a list of answers is given to answer_list argument. Note that the saved template file is not intended to be run as is, but only to provide a starting structure for a cleaning script.

Usage

1
make_dua_template(file_name, include_notes = TRUE, answer_list = NULL)

Arguments

file_name

Name with path of template script.

include_notes

If TRUE, the template file will include notes and suggestions for completing the script; default value is TRUE.

answer_list

List of answer strings to provide if you don't want to answer questions interactively. See details for questions and expected input type. Leave as default NULL for interactive mode.

Details

Questions to answer if using the answer_list argument:

  1. Do you want to set the DUA crosswalk file? 'Yes' or 'No'

    1. DUA crosswalk file (with path): '< file name with path >'

  2. Do the data need to be deidentified? 'Yes' or 'No'

    1. Would like to select the ID column now? 'Yes' or 'No'

    2. ID column name: '< column name string >'

If answers to questions (1) and (2) are No, then strings for 1(a), 2(a), and 2(b) can be left empty since they will be ignored.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
## run interactively
make_dua_template('data_clean.R')

## ...and don't include extra notes
make_dua_template('data_clean.R', include_notes = FALSE)

## End(Not run)

## make template to be filled in
file <- file.path(tempdir(), 'data_clean.R')
make_dua_template(file, answer_list = list('No','','No','',''))

## show
writeLines(readLines(file))

btskinner/duawranglr documentation built on June 13, 2021, 6:52 p.m.