Importing a (pre)registration form from embedded JSON from a URL

(Pre)registration forms can be directly imported from an URL. For example, the vignette about how to create a preregistration form stores the two forms embedded as JSON. These can be imported again as a preregr form.

importedExample <-
  preregr::import_from_html(
    "https://r-packages.gitlab.io/preregr/articles/creating_prereg_form.html"
  );

This imports the first form, the example that is created in that vignette:

importedExample;
#> 
#> -- (Pre)registration form ------------------------------------------------------
#> 
#> i Title: Minimal form with only a few fields
#> i Author: Stibbons, P.
#> i Date: 2022-01-11
#> i This form has 2 items in 1 section.

Or, to view the form:

preregr::form_show(importedExample);
#> 
#> -- (Pre)registration form ------------------------------------------------------
#> 
#> i Title: Minimal form with only a few fields
#> i Author: Stibbons, P.
#> i Date: 2022-01-11
#> 
#> -- Instructions ----------------------------------------------------------------
#> 
#> -- Instructions --
#> 
#> This form is simple, so it doesn't require much instruction. Still, it's
#> advisable to always RTFM, and in the case of (pre)registration forms, the
#> instructions are the manual. So better read closely!
#> 
#> -- Sections and items ----------------------------------------------------------
#> 
#> -- Section: Only Section --
#> 
#> i Study Title [study_title]: Think of a catchy title, preferably with a colon in the middle. Bonus points for pop culture references.
#> 
#> i 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.
#> 

Initiating a (pre)registration from an imported form

We can now initialize a new (pre)registration using this form:

freshPrereg <-
  preregr::prereg_initialize(
    importedExample
  );

Et voila, an empty (pre)registration:

freshPrereg;
#> 
#> -- (Pre)registration specification ---------------------------------------------
#> i Form: Minimal form with only a few fields
#> i 2 fields (0 completed, 2 empty)

Selecting the form to import

To import the second form that is embedded in that vignette (the full form for systematic reviews), we can pass a value for select:

importedExample_2 <-
  preregr::import_from_html(
    "https://r-packages.gitlab.io/preregr/articles/creating_prereg_form.html",
    select = 2
  );

If we now knit this form into this vignette again, it will again be included as JSON as well:

preregr::form_knit(importedExample);

Minimal form with only a few fields

Instructions

Instructions

This form is simple, so it doesn’t require much instruction. Still, it’s advisable to always RTFM, and in the case of (pre)registration forms, the instructions are the manual. So better read closely!

Sections and items

Section: Only Section

Study Title
study_title
Think of a catchy title, preferably with a colon in the middle. Bonus points for pop culture references.
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.

Saving a form to a spreadsheet

Alternatively, you can export the form to a local spreadsheet file so you can import it later:

preregr::form_to_xlsx(
  formExample,
  file = "C:/Data/Research/amazing-new-project/prereg-form.xlsx"
);