This vignette shows the general purpose and basic functionality of
the rlistings
R package.
The rlistings
R package contains value formatting and
ASCII rendering infrastructure for tables and listings useful for
clinical trials and other statistical analysis. The core functionality
is built on top of the formatters
package.
Some of the key features currently available to customize listings
created using the rlistings
package include:
The index of all available rlistings
functions can be
found on the rlistings
website functions reference.
The rlistings
package is intended for use in creating
simple one-dimensional listings. For construction of more complex tables
see the rtables
package.
With the basic framework provided in this package, a
data.frame
object can be easily converted into a listing
using the as_listing
function with several optional
customizations available.
A listing, at its core, is a set of observation-level data which is
to be rendered with particular formatting but without any sort of
aggregation or further analysis. In practice, this translates to to a
classed data.frame
(or tbl_df
) object with a
specialized print method. This means that, unlike tables created with
rlistings
’ sibling package rtables
, a listing
object is fundamentally the incoming data.frame
with a few
annotations attached to it.
In the R code below we will give a basic example of how to create an
rlistings
listing from a pre-processed data frame.
We first load in the rlistings
package.
For the purpose of this example we will use the dummy ADAE dataset
provided within the formatters
package as our data frame,
which consists of 48 columns of adverse event patient data, and one or
more rows per patient.
Now we will create our listing.
The df
parameter sets our data.frame
object. The disp_cols
argument takes a vector of names of
any columns taken from the data frame that should be included in the
listing. Column headers are set by the label
attribute of
each given variable. If there is no label associated with a given
variable then the variable name will be taken as a header instead. For
this example we will choose 8 arbitrary columns to display - 5 specific
to the patient and 3 relating to the adverse event.
Since the dataset consists of 1934 rows in total, we will use the
head
function to print only the first 15 rows of the
listing.
lsting <- as_listing(
df = adae,
disp_cols = c("USUBJID", "AETOXGR", "ARM", "AGE", "SEX", "RACE", "AEDECOD", "AESEV"),
)
head(lsting, 15)
#> Study Identifier Unique Subject Identifier Analysis Toxicity Grade Description of Planned Arm Age Sex Race Dictionary-Derived Term Severity/Intensity
#> ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#> AB12345 AB12345-BRA-1-id-134 3 A: Drug X 47 M WHITE dcd B.2.1.2.1 MODERATE
#> AB12345-BRA-1-id-134 3 A: Drug X 47 M WHITE dcd D.1.1.4.2 MODERATE
#> AB12345-BRA-1-id-134 2 A: Drug X 47 M WHITE dcd A.1.1.1.2 MODERATE
#> AB12345-BRA-1-id-134 2 A: Drug X 47 M WHITE dcd A.1.1.1.2 MODERATE
#> AB12345-BRA-1-id-141 3 C: Combination 35 F WHITE dcd B.2.1.2.1 MODERATE
#> AB12345-BRA-1-id-141 1 C: Combination 35 F WHITE dcd D.2.1.5.3 MILD
#> AB12345-BRA-1-id-141 1 C: Combination 35 F WHITE dcd A.1.1.1.1 MILD
#> AB12345-BRA-1-id-141 2 C: Combination 35 F WHITE dcd A.1.1.1.2 MODERATE
#> AB12345-BRA-1-id-141 1 C: Combination 35 F WHITE dcd A.1.1.1.1 MILD
#> AB12345-BRA-1-id-141 5 C: Combination 35 F WHITE dcd D.1.1.1.1 SEVERE
#> AB12345-BRA-1-id-236 5 B: Placebo 32 M BLACK OR AFRICAN AMERICAN dcd B.1.1.1.1 SEVERE
#> AB12345-BRA-1-id-236 5 B: Placebo 32 M BLACK OR AFRICAN AMERICAN dcd B.1.1.1.1 SEVERE
#> AB12345-BRA-1-id-236 5 B: Placebo 32 M BLACK OR AFRICAN AMERICAN dcd B.1.1.1.1 SEVERE
#> AB12345-BRA-1-id-265 2 C: Combination 25 M WHITE dcd C.2.1.2.1 MODERATE
#> AB12345-BRA-1-id-265 3 C: Combination 25 M WHITE dcd D.1.1.4.2 MODERATE
In the listing output above you can see that there are several rows
associated with each patient, resulting in many instances of repeated
values over several columns. This can cleaned up by setting key columns
with the key_cols
argument.
We can also declare the set of (non-key) display columns by
compliment, via the non_disp_col
argument. If specifies
this argument accepts names of columns which will non be displayed. All
other non-key columns are then displayed.
lsting <- as_listing(
df = adae,
non_disp_cols = tail(names(adae), 8))
head(lsting, 15)
#> Study Identifier Unique Subject Identifier Subject Identifier for the Study Study Site Identifier Age Sex Race Country Investigator Identifier Description of Planned Arm Planned Arm Code Description of Actual Arm Actual Arm Code Stratification Factor 1 Stratification Factor 2 Continous Level Biomarker 1 Categorical Level Biomarker 2 Intent-To-Treat Population Flag Safety Population Flag Response Evaluable Population Flag Biomarker Evaluable Population Flag Date of Randomization Datetime of First Exposure to Treatment Datetime of Last Exposure to Treatment End of Study Status End of Study Date End of Study Relative Day Reason for Discontinuation from Study Date of Death Date Last Known Alive NOT A STANDARD BUT NEEDED FOR RCD Analysis Sequence Number Sponsor-Defined Identifier Reported Term for the Adverse Event Lowest Level Term Dictionary-Derived Term High Level Term High Level Group Term Body System or Organ Class Primary System Organ Class
#> ———————————————————————————————————————————————————————————————————————————â