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

Fix lint, apply styler #175

Merged
merged 5 commits into from Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 17 additions & 9 deletions R/rlistings.R
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
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
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