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

Introduction

This guidance ensures consistency across the vignettes in the {admiral} package in terms of content, structure and code execution. As a general rule, the vignette workflow defined in r-pkgs.org is followed.

Metadata

Each vignette in {admiral} should start with the following metadata.

---
title: "<Title>"
output:  rmarkdown::html_vignette:
vignette: >
  %\VignetteIndexEntry{<Title>}
  %\VignetteEngine{knitr::rmarkdown}
---

The <Title> of the vignette should be meaningful.

Markdown

Default Options

If any chunks are used within the vignette, the following options should be set after the metadata to ensure that the chunks are rendered consistently across all vignettes.

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

Format Sections

Table of Contents

Headings must be title case and start from Heading 1:

# Heading 1
This is the description of my first section.

## Heading 1.1
This is the description of my first sub-section within my first section.

## Heading 1.2
This is the description of my second sub-section within my first section.

The first section gives a brief introduction of the vignette. The last sub-section of the introduction should describe the packages required to run the {admiral} functions. The {admiral} package should be described first.

# Introduction

This is the introduction of my vignette.

## Required Packages
`r ''````r
library(admiral)
# <all packages used in the vignette>
```

The warning = FALSE and message = FALSE options are there to prevent the usual messages:

Attaching package: 'xxxx'

The following objects are masked from 'package:yyyyy':

fun1, fun2

Conventions

General Conventions

  The `date` parameter of the `derive_my_var()` function expects a date variable, e.g., `ADT`.
library(lubridate)
library(dplyr)
library(admiral.test)
library(DT)
library(admiral)

data(vs)
      vs1 <- vs %>%
        derive_vars_dt(
        new_vars_prefix = "A",
        dtc = VSDTC,
        date_imputation = "FIRST"
      )
      vs1 <- vs %>%
        derive_vars_dt(
        new_vars_prefix = "A",
        dtc = VSDTC,
        date_imputation = "FIRST"
      )

      dataset_vignette(
        vs1,
        display_vars = vars(USUBJID, VSTESTCD, VISIT, VSDTC, ADT),
        filter = VSTESTCD == "WEIGHT"
      )

Note: The call to get the formatted dataset would be:

  ```r
  dataset_vignette(
    vs1, 
    display_vars=vars(USUBJID, VSTESTCD, VISIT, VSDTC, ADT),
    filter = VSTESTCD == "WEIGHT"
  )
  ```

Displaying many big datasets on a vignette, may require a long time to load the page and may cause messages from the browser that the page is not responsive. In this case the number of displayed observations should be restricted either by restricting the source datasets at the beginning of the vignette or in the call of dataset_vignette() if only some calls are affected.

Conventions for ADaM Workflow

For vignettes describing an ADaM workflow,

# Programming Workflow

* [Read in Data](#readdata)
* [Derive/Impute End and Start Analysis Date/time and Relative Day](#datetime)
* ...
* [Assign `ASEQ`](#aseq)

## Read in Data {#readdata}
## Derive/Impute End and Start Analysis Date/time and Relative Day {#datetime}
## ...
## Assign `ASEQ` {#aseq}

# Another Section

# Example Script
ADaM | Sample Code
---- | --------------
ADxx | [ad_adxx.R](https://github.com/pharmaverse/admiral/blob/main/inst/templates/ad_adxx.R){target="_blank"}

All ADSL variables which are required for any derivation are merged to the SDTM dataset before the first derivation. These ADSL variables have to be added to the by-variables for derivations which add observations. This ensures that the ADSL variables are populated for the new observations. A adsl_vars variable should be created at the beginning of the script and added to the by_vars parameter for derivations which add observations.

ADSL variables which should be in the final dataset but are not required for any derivation are merged to the dataset after the last derivation.



epijim/admiral documentation built on Feb. 13, 2022, 12:15 a.m.