This vignette shows you how to gather the specifications for all of your analysis project data sets, assemble into a single object, and use that object to render a project-wide define document.
library(yspec)
If my project had 3 analysis data sets, one for PK, one for PKPD, and one for
AEs, we create a specification object for each one. Here, we're using
load_spec_ex()
because we're using example material from the package. You
should use ys_load()
for your project and give the full path to the
yaml specification file.
sp1 <- load_spec_ex("DEM104101F_PK.yml") sp2 <- load_spec_ex("DEM104101F_PKPD.yml") sp3 <- load_spec_ex("DEM104101F_AE.yml")
Each object looks something like
sp1
This includes our usual information about the columns in the data set.
We take these specification objects and create a project object from them.
proj <- ys_project(sp1,sp2,sp3) proj
Now, for each specification object, we have a data / specification name as well as a description (along with some other information).
This file is by default saved to a temporary location. But you can also save it locally and keep it as a part of the project.
```{txt, code = readLines(get_meta(proj)[["spec_file"]])}
To do this, we tucked some additional information into the data set specification file. For example, the specification file for the first spec object (`sp1`) looks like this: ```{txt, code = readLines(yspec_yml_file(sp1))}
In the SETUP__
block, we included a description; this is required to make a
project object from data objects. There also is a name
that defaults to the
stem of the data specification file. We also optionally included projectnumber
and sponsor
. These will get inserted into the define document when the
MetrumRG Rmarkdown template is used.
Now, we have an object with the project information put together. The essential contents of that object have been written to a project spec file and can be used to template the creation of a project data specification file.
ys_document(proj, stem = "define_doc")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.