The goal of tidytlg is to generate table, listings, and graphs (TLG) using Tidyverse. This can be achieved multiple ways with this package.
# install.packages("devtools")
::install_github("pharmaverse/tidytlg") devtools
library(dplyr)
library(tidytlg)
# Note cdisc_adsl is built into the package for use
<- cdisc_adsl %>%
ittpop filter(ITTFL == "Y")
# frequency of Intend-to-Treat patients by planned treatment
<- freq(ittpop,
tbl1 rowvar = "ITTFL",
statlist = statlist("n"),
colvar = "TRT01P",
rowtext = "Analysis Set: Intend-to-Treat Population",
subset = ITTFL == "Y")
# N, MEAN (SD), MEDIAN, RANGE, IQ Range of age by planned treatment
<- univar(ittpop,
tbl2 rowvar = "AGE",
colvar = "TRT01P",
row_header = "Age (Years)")
# frequency of Race by planned treatment
<- freq(ittpop,
tbl3 rowvar = "RACE",
statlist = statlist(c("N", "n (x.x%)")),
colvar = "TRT01P",
row_header = "Race, n(%)")
# combine results together
<- bind_table(tbl1, tbl2, tbl3)
tbl
# conver to hux object -----------------------------------------------------------------
gentlg(huxme = tbl ,
orientation = "landscape",
file = "DEMO",
title = "Custom Method",
footers = "Produced with tidytlg",
colspan = list(c("", "", "Xanomeline", "Xanomeline")),
colheader = c("", "Placebo", "High", "Low"),
wcol = .30)
library(dplyr)
library(tidytlg)
<- cdisc_adsl
adsl
<- tibble::tribble(
table_metadata ~anbr,~func, ~df, ~rowvar, ~rowtext, ~row_header, ~statlist, ~subset,
1, "freq", "adsl", "ITTFL", "Analysis set: itt", NA, statlist("n"), "ITTFL == 'Y'",
2, "univar", "adsl", "AGE", NA, "Age (Years)", NA, NA,
3, "freq", "adsl", "RACE", NA, "Race, n(%)", statlist(c("N", "n (x.x%)")), NA
%>%
) mutate(colvar = "TRT01PN")
<- generate_results(table_metadata,
tbl column_metadata_file = system.file("extdata/column_metadata.xlsx", package = "tidytlg"),
tbltype = "type1")
# conver to hux object -----------------------------------------------------------------
<- "Table01"
tblid
gentlg(huxme = tbl,
orientation = "landscape",
file = tblid,
title_file = system.file("extdata/titles.xls", package = "tidytlg"),
wcol = .30)