Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update, greenci, skip test if dplyr not available #224

Merged
merged 14 commits into from
Sep 3, 2024
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 @@
---

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

Check warning on line 18 in vignettes/col_formatting.Rmd

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=vignettes/col_formatting.Rmd,line=18,col=30,[trailing_whitespace_linter] Trailing whitespace is superfluous.
pawelru marked this conversation as resolved.
Show resolved Hide resolved
requireNamespace,
logical(1),
quietly = TRUE
))
)
```

Expand Down Expand Up @@ -46,10 +53,11 @@

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 @@

## 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
15 changes: 12 additions & 3 deletions vignettes/ref_footnotes.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@
---

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

Check warning on line 18 in vignettes/ref_footnotes.Rmd

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=vignettes/ref_footnotes.Rmd,line=18,col=30,[trailing_whitespace_linter] Trailing whitespace is superfluous.
pawelru marked this conversation as resolved.
Show resolved Hide resolved
requireNamespace,
logical(1),
quietly = TRUE
))
)
```

Expand All @@ -32,10 +39,12 @@

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)
require(dplyr)

shajoezhu marked this conversation as resolved.
Show resolved Hide resolved
```

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 +106,7 @@
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
Loading