View source: R/cto_form_files.R
| cto_form_languages | R Documentation |
These functions retrieve auxiliary files and templates associated with a deployed SurveyCTO form. All these functions require a stateful session to work.
cto_form_languages() retrieves the list of languages defined in the form.
cto_form_stata_template() downloads a Stata .do file template for
importing submitted data.
cto_form_printable() downloads a printable (HTML) version of the form
definition.
cto_form_mail_template() downloads a mail merge template for the form.
All downloads are saved locally and their file paths are returned invisibly.
cto_form_languages(form_id)
cto_form_stata_template(
form_id,
dir = getwd(),
lang = NULL,
csv_dir = NULL,
dta_dir = NULL
)
cto_form_printable(
form_id,
dir = getwd(),
lang = NULL,
relevancies = FALSE,
constraints = FALSE
)
cto_form_mail_template(form_id, dir = getwd(), type = 2, group_names = FALSE)
form_id |
A character string giving the unique SurveyCTO form ID. |
dir |
A character string specifying the directory where downloaded files will be saved. Defaults to the current working directory. |
lang |
Optional character string giving the language identifier
(for example, |
csv_dir |
Optional character string giving the directory where the CSV
dataset will eventually be stored. This value is embedded in the generated
Stata |
dta_dir |
Optional character string giving the directory where the Stata
|
relevancies |
Logical; if |
constraints |
Logical; if |
type |
Integer (0–2) specifying the format of the mail merge template:
|
group_names |
Logical; if |
cto_form_languages() returns a list containing the available languages
and the index of the default language (1-based).
All other functions return the local file path of the downloaded file, invisibly.
Other Form Management Functions:
cto_form_attachment(),
cto_form_data(),
cto_form_data_attachment(),
cto_form_dofile(),
cto_form_metadata()
## Not run:
form <- "household_survey"
# 1. List available form languages
langs <- cto_form_languages(form)
print(langs)
# 2. Download a Stata import template
# Provide future CSV/DTA locations so the .do file is ready to run
cto_form_stata_template(
form_id = form,
dir = "downloads/",
csv_dir = "C:/Data",
dta_dir = "C:/Data"
)
# 3. Download a printable form with logic displayed
cto_form_printable(
form_id = form,
dir = "documentation/",
relevancies = TRUE,
constraints = TRUE
)
# 4. Download a mail-merge template
cto_form_mail_template(
form_id = form,
dir = "templates/",
type = 2
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.