Add an instruction, section, or item to a (pre)registration form
form_add_instruction(x, heading, description, overwrite = TRUE)
form_add_section(x, id, label, description, overwrite = TRUE)
form_add_item(
x,
id,
label,
description,
section_id,
valueTemplate = "string",
validValues = NA,
validation = NA,
overwrite = TRUE
)
The (pre)registration form as created by form_create()
.
The instruction's heading
The description of the instruction, section, or item
Whether to overwrite existing content or append the new content
The identifier of the section or item
The label (i.e. title) of the section or item
The section identifier of the section the item should be placed in
The name of the value template of the item
The valid values (for categorical items)
The validation statement (an R expression)
The modified (pre)registration form
### Create an empty example form
exampleForm <-
preregr::form_create(
title = "Example form",
version = "0.1.0"
) |>
preregr::form_show();
#>
#> ── (Pre)registration form ──────────────────────────────────────────────────────
#>
#> ℹ Title: Example form
#> ℹ Author: NA
#> ℹ Date: 2023-05-04
#>
#> ── Instructions ────────────────────────────────────────────────────────────────
#>
#> ── First instruction ──
#>
#> Actual instructions
#>
#> ── Sections and items ──────────────────────────────────────────────────────────
#>
#> ── Section: Example Section ──
#>
#> ℹ Example Label [example_item]: Example item description
#>
### Add some stuff;
exampleForm <-
exampleForm |>
preregr::form_add_instruction(
heading = "First Real Instruction",
description = "Which normally also contains real instructions here"
) |>
preregr::form_add_section(
id = "first_section",
label = "First Real Section",
description = "This section is very, very important."
) |>
preregr::form_add_section(
id = "second_section",
label = "Second Real Section",
description = "This section is even more important then the first one."
) |>
preregr::form_add_item(
id = "study_title",
label = "Study Title",
section_id = "first_section",
description = paste0(
"Think of a catching title, preferably with a colon in ",
"the middle. Bonus points for pop culture references."
)
) |>
preregr::form_add_item(
id = "study_authors",
label = "Authors",
section_id = "first_section",
description = "Maybe list the authors, too."
) |>
preregr::form_add_item(
id = "registration_type",
label = "Registration type",
section_id = "second_section",
description = paste0(
"Describe briefly why you are (pre)registering this ",
"study. For example, this might be a preregistration ",
"to allow others to know you're doing this study; or to ",
"make it clear you value transparency in science; or to ",
"remember your original plans later on. Or this might be ",
"a registration to update your plans after the data came ",
"in; or to document pragmatic changes in plans."
)
);
### Show the result of our hard labour
preregr::form_show(exampleForm);
#>
#> ── (Pre)registration form ──────────────────────────────────────────────────────
#>
#> ℹ Title: Example form
#> ℹ Author: NA
#> ℹ Date: 2023-05-04
#>
#> ── Instructions ────────────────────────────────────────────────────────────────
#>
#> ── First Real Instruction ──
#>
#> Which normally also contains real instructions here
#>
#> ── Sections and items ──────────────────────────────────────────────────────────
#>
#> ── Section: First Real Section ──
#>
#> ℹ Study Title [study_title]: Think of a catching title, preferably with a colon in the middle. Bonus points for pop culture references.
#>
#> ℹ Authors [study_authors]: Maybe list the authors, too.
#>
#>
#> ── Section: Second Real Section ──
#>
#> ℹ Registration type [registration_type]: Describe briefly why you are (pre)registering this study. For example, this might be a preregistration to allow others to know you're doing this study; or to make it clear you value transparency in science; or to remember your original plans later on. Or this might be a registration to update your plans after the data came in; or to document pragmatic changes in plans.
#>