Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pharmaverse/tidytlg
The goal of tidytlg is to generate tables, listings, and graphs (TLG) using Tidyverse.
https://github.com/pharmaverse/tidytlg
Last synced: about 2 months ago
JSON representation
The goal of tidytlg is to generate tables, listings, and graphs (TLG) using Tidyverse.
- Host: GitHub
- URL: https://github.com/pharmaverse/tidytlg
- Owner: pharmaverse
- License: other
- Created: 2022-12-05T14:12:42.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-28T18:01:01.000Z (4 months ago)
- Last Synced: 2024-05-29T07:25:19.731Z (4 months ago)
- Language: Rich Text Format
- Homepage: https://pharmaverse.github.io/tidytlg/
- Size: 2.84 MB
- Stars: 32
- Watchers: 2
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# tidytlg
[![CRAN status](https://www.r-pkg.org/badges/version/tidytlg)](https://CRAN.R-project.org/package=tidytlg)The goal of tidytlg is to generate table, listings, and graphs (TLG) using Tidyverse. This can be achieved multiple ways with this package.
* Functional method: build a custom script for each TLG
* Metadata method: build a generic script that utilizes column and table metadata to produce each TLG result## Installation
### Development version
```{r, eval = FALSE}
# install.packages("devtools")
devtools::install_github("pharmaverse/tidytlg")
```## Functional method example
```{r custom, eval = FALSE}
library(dplyr)
library(tidytlg)# Note cdisc_adsl is built into the package for use
ittpop <- cdisc_adsl %>%
filter(ITTFL == "Y")# frequency of Intend-to-Treat patients by planned treatment
tbl1 <- freq(ittpop,
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
tbl2 <- univar(ittpop,
rowvar = "AGE",
colvar = "TRT01P",
row_header = "Age (Years)")# frequency of Race by planned treatment
tbl3 <- freq(ittpop,
rowvar = "RACE",
statlist = statlist(c("N", "n (x.x%)")),
colvar = "TRT01P",
row_header = "Race, n(%)")# combine results together
tbl <- bind_table(tbl1, tbl2, tbl3)# 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)
```## Metadata method example
```{r metadata, eval = FALSE}
library(dplyr)
library(tidytlg)adsl <- cdisc_adsl
table_metadata <- tibble::tribble(
~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")tbl <- generate_results(table_metadata,
column_metadata_file = system.file("extdata/column_metadata.xlsx", package = "tidytlg"),
tbltype = "type1")# conver to hux object -----------------------------------------------------------------
tblid <- "Table01"gentlg(huxme = tbl,
orientation = "landscape",
file = tblid,
title_file = system.file("extdata/titles.xls", package = "tidytlg"),
wcol = .30)
```