Skip to content

Commit

Permalink
Fix lint, apply styler (#175)
Browse files Browse the repository at this point in the history
Closes #174
  • Loading branch information
edelarua committed Oct 23, 2023
1 parent 0610357 commit dda9a17
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
26 changes: 17 additions & 9 deletions R/rlistings.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ as_listing <- function(df,
main_footer = NULL,
prov_footer = NULL) {
if (length(non_disp_cols) > 0 && length(intersect(key_cols, non_disp_cols)) > 0) {
stop("Key column also listed in non_disp_cols. All key columns are by",
" definition display columns.")
stop(
"Key column also listed in non_disp_cols. All key columns are by",
" definition display columns."
)
}
if (!is.null(disp_cols) && !is.null(non_disp_cols)) {
stop("Got non-null values for both disp_cols and non_disp_cols. This is not supported.")
Expand All @@ -153,12 +155,16 @@ as_listing <- function(df,
cols <- disp_cols
}
if (!all(sapply(default_formatting, is, class2 = "fmt_config"))) {
stop("All format configurations supplied in `default_formatting`",
" must be of type `fmt_config`.")
stop(
"All format configurations supplied in `default_formatting`",
" must be of type `fmt_config`."
)
}
if (!(is.null(col_formatting) || all(sapply(col_formatting, is, class2 = "fmt_config")))) {
stop("All format configurations supplied in `col_formatting`",
" must be of type `fmt_config`.")
stop(
"All format configurations supplied in `col_formatting`",
" must be of type `fmt_config`."
)
}

df <- as_tibble(df)
Expand Down Expand Up @@ -197,9 +203,11 @@ as_listing <- function(df,
default_formatting[[col_fmt_class]]
} else {
if (!"all" %in% names(default_formatting)) {
stop("Format configurations must be supplied for all listing columns. ",
"To cover all remaining columns please add an 'all' configuration",
" to `default_formatting`.")
stop(
"Format configurations must be supplied for all listing columns. ",
"To cover all remaining columns please add an 'all' configuration",
" to `default_formatting`."
)
}
default_formatting[["all"]]
}
Expand Down
4 changes: 2 additions & 2 deletions man/matrix_form-listing_df-method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions tests/testthat/test-listings.R
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,10 @@ testthat::test_that("unique_rows removes duplicate rows from listing", {
)
result_strings <- matrix_form(lsting)$strings
expected_strings <- matrix(
c("Planned Arm Code", "ARM A", "", "", "", "ARM B", "", "", "ARM C", "", "", "",
"Sex", "M", "F", "UNDIFFERENTIATED", "U", "F", "M", "U", "M", "F", "U", "UNDIFFERENTIATED"),
c(
"Planned Arm Code", "ARM A", "", "", "", "ARM B", "", "", "ARM C", "", "", "",
"Sex", "M", "F", "UNDIFFERENTIATED", "U", "F", "M", "U", "M", "F", "U", "UNDIFFERENTIATED"
),
ncol = 2,
dimnames = list(c(), c("ARMCD", "SEX"))
)
Expand Down
5 changes: 3 additions & 2 deletions vignettes/rlistings.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ are then displayed.

```{r}
lsting <- as_listing(
df = adae,
non_disp_cols = tail(names(adae), 8))
df = adae,
non_disp_cols = tail(names(adae), 8)
)
head(lsting, 15)
```

Expand Down

0 comments on commit dda9a17

Please sign in to comment.