Skip to content

Commit

Permalink
Merge e9ccb68 into dcd8214
Browse files Browse the repository at this point in the history
  • Loading branch information
shajoezhu committed Sep 3, 2024
2 parents dcd8214 + e9ccb68 commit 25fb0eb
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 10 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ URL: https://insightsengineering.github.io/rlistings/,
https://github.com/insightsengineering/rlistings/
BugReports: https://github.com/insightsengineering/rlistings/issues
Depends:
formatters (>= 0.5.8),
formatters (>= 0.5.8.9006),
methods,
tibble (>= 2.0.0)
Imports:
Expand All @@ -39,7 +39,8 @@ Suggests:
testthat (>= 3.1.5),
withr (>= 2.0.0)
VignetteBuilder:
knitr
knitr,
rmarkdown
Config/Needs/verdepcheck: insightsengineering/formatters,
tidyverse/tibble, mllg/checkmate, tidyverse/dplyr, yihui/knitr,
r-lib/lifecycle, rstudio/rmarkdown, gagolews/stringi, r-lib/testthat,
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
library(dplyr)

anl <- ex_adsl
anl <- anl[1:10, c("USUBJID", "ARM", "BMRKR1")]
anl <- var_relabel(anl,
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-export.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ testthat::test_that("Listing print correctly", {
})

testthat::test_that("key columns repeat with export_as_txt", {
skip_if_not_installed("dplyr")
require("dplyr", quietly = TRUE)
# pre-processing and ordering
tmp_data <- ex_adae %>%
dplyr::slice(1:30) %>%
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-matrix_form.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
testthat::test_that("matrix_form keeps relevant information and structure about the listing", {
skip_if_not_installed("dplyr")
require("dplyr", quietly = TRUE)

my_iris <- iris %>%
slice(c(16, 3)) %>%
mutate("fake_rownames" = c("mean", "mean"))
Expand Down
12 changes: 12 additions & 0 deletions tests/testthat/test-paginate_listing.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
testthat::test_that("pagination works vertically", {
skip_if_not_installed("dplyr")
require("dplyr", quietly = TRUE)

# pre-processing and ordering
tmp_data <- ex_adae %>%
dplyr::slice(1:30) %>%
Expand All @@ -22,6 +25,9 @@ testthat::test_that("pagination works vertically", {
})

testthat::test_that("horizontal pagination with 0 or 1 key column specified works correctly", {
skip_if_not_installed("dplyr")
require("dplyr", quietly = TRUE)

# pre-processing and ordering
tmp_data <- ex_adae %>%
dplyr::slice(1:30) %>%
Expand Down Expand Up @@ -84,6 +90,9 @@ testthat::test_that("horizontal pagination with 0 or 1 key column specified work
})

testthat::test_that("listing works with no vertical pagination", {
skip_if_not_installed("dplyr")
require("dplyr", quietly = TRUE)

# pre-processing and ordering
tmp_data <- ex_adae %>%
dplyr::slice(1:30) %>%
Expand All @@ -104,6 +113,9 @@ testthat::test_that("listing works with no vertical pagination", {
})

testthat::test_that("checking vertical pagination line calculation.", {
skip_if_not_installed("dplyr")
require("dplyr", quietly = TRUE)

# pre-processing and ordering
tmp_data <- ex_adae %>%
dplyr::slice(1:30) %>%
Expand Down
14 changes: 11 additions & 3 deletions vignettes/col_formatting.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ vignette: >
---

```{r, include = FALSE}
suggested_dependent_pkgs <- c("dplyr")
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
comment = "#>",
eval = all(vapply(
suggested_dependent_pkgs,
requireNamespace,
logical(1),
quietly = TRUE
))
)
```

Expand Down Expand Up @@ -46,10 +53,11 @@ The `default_formatting` argument can use the same format configuration for all

To demonstrate, we will create a basic listing below and customize formatting using the `default_formatting` parameter.

We begin by loading in the `rlistings` package.
We begin by loading in the `rlistings` package.

```{r, message=FALSE}
library(rlistings)
require(dplyr)
```

For 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. For the purpose of this example, we will subset the data and only use the first 15 records of the dataset. We will create some `NA` values in the data to showcase how `NA` values can be formatted, and sort the data by what will be our key columns.
Expand Down Expand Up @@ -140,7 +148,7 @@ In the output above, the `all` format configuration, which originally applied to

## Column-Wise Formatting in `as_listing`

In this section, we will demonstrate how custom formatting can be applied on a column-by-column basis rather than to all columns of a specified data class or an entire listing at once.
In this section, we will demonstrate how custom formatting can be applied on a column-by-column basis rather than to all columns of a specified data class or an entire listing at once.

Take, for example, `lsting_4` created in the previous section.

Expand Down
14 changes: 11 additions & 3 deletions vignettes/ref_footnotes.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ vignette: >
---

```{r, include = FALSE}
suggested_dependent_pkgs <- c("dplyr")
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
comment = "#>",
eval = all(vapply(
suggested_dependent_pkgs,
requireNamespace,
logical(1),
quietly = TRUE
))
)
```

Expand All @@ -32,10 +39,11 @@ When creating a listing with the `rlistings` package, you may want to add refere

To demonstrate, we will create a basic listing below.

We begin by loading in the `rlistings` package.
We begin by loading in the `rlistings` package.

```{r, message=FALSE}
library(rlistings)
library(dplyr)
```

For 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. For the purpose of this example, we will subset the data and only use the first 30 records of the dataset.
Expand Down Expand Up @@ -97,7 +105,7 @@ lsting <- as_listing(
lsting
```

Additional referential footnotes can be added to the data be repeating the above steps.
Additional referential footnotes can be added to the data be repeating the above steps.

For example, we can add the second referential footnote to the `ASTDY` column for imputed analysis start days. We use dummy variable `ASTDTF` to indicate imputed analysis start dates. When adding referential footnotes to numeric variables, the variables must be converted to factors.

Expand Down

0 comments on commit 25fb0eb

Please sign in to comment.