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

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

(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;

Or, to view the form:

preregr::form_show(importedExample);

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;

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://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);

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"
);


Try the preregr package in your browser

Any scripts or data that you put into this service are public.

preregr documentation built on May 31, 2023, 7:10 p.m.