vignettes/importing_form_from_url.Rmd
importing_form_from_url.Rmd
(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://preregr.opens.science/articles/creating_prereg_form.html"
);
This imports the first form, the example that is created in that vignette:
importedExample;
#>
#> ── (Pre)registration form ──────────────────────────────────────────────────────
#>
#> ℹ Title: Minimal form with only a few fields
#> ℹ Author: Stibbons, P.
#> ℹ Date: 2023-05-04
#> ℹ This form has 2 items in 1 section.
Or, to view the form:
preregr::form_show(importedExample);
#>
#> ── (Pre)registration form ──────────────────────────────────────────────────────
#>
#> ℹ Title: Minimal form with only a few fields
#> ℹ Author: Stibbons, P.
#> ℹ Date: 2023-05-04
#>
#> ── 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.
#>
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 ─────────────────────────────────────────────
#> ℹ Form: Minimal form with only a few fields
#> ℹ 2 fields (0 completed, 2 empty)
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://preregr.opens.science/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);
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"
);