Skip to content

Commit

Permalink
Simple code update.
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Jun 2, 2023
1 parent 0e77b41 commit ec3cd3c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions R/adorn_totals.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ adorn_totals <- function(dat, where = "row", fill = "-", na.rm = TRUE, name = "T
if ("col" %in% where) {
# Add totals col
row_totals <- dat %>%
dplyr::select(dplyr::all_of(cols_to_total)) %>%
dplyr::select_if(is.numeric) %>%
dplyr::select(dplyr::all_of(cols_to_total) & dplyr::where(is.numeric)) %>%
dplyr::transmute(Total = rowSums(., na.rm = na.rm))

dat[[name[2]]] <- row_totals$Total
Expand Down
4 changes: 2 additions & 2 deletions R/remove_empties.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#' dd %>% remove_empty("rows")
#' # solution: preprocess to convert whitespace/empty strings to NA,
#' # _then_ remove empty (all-NA) rows
#' dd %>% mutate(across(is.character,~na_if(trimws(.),""))) %>%
#' dd %>% mutate(across(where(is.character),~na_if(trimws(.),""))) %>%
#' remove_empty("rows")
#' @export
remove_empty <- function(dat, which = c("rows", "cols"), cutoff=1, quiet=TRUE) {
Expand Down Expand Up @@ -93,7 +93,7 @@ remove_empty <- function(dat, which = c("rows", "cols"), cutoff=1, quiet=TRUE) {
#'
#' # To find the columns that are constant
#' data.frame(A=1, B=1:3) %>%
#' dplyr::select_at(setdiff(names(.), names(remove_constant(.)))) %>%
#' dplyr::select(!dplyr::all_of(names(remove_constant(.)))) %>%
#' unique()
#' @importFrom stats na.omit
#' @family remove functions
Expand Down
2 changes: 1 addition & 1 deletion man/remove_constant.Rd

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

2 changes: 1 addition & 1 deletion man/remove_empty.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/test-clean-names.R
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ test_that("tbl_graph/tidygraph", {
tidygraph::play_erdos_renyi(10, 0.5) %>%
# create nodes wi
tidygraph::bind_nodes(test_df) %>%
tidygraph::mutate_all(tidyr::replace_na, 1)
dplyr::mutate(dplyr::across(dplyr::where(is.numeric), ~ dplyr::coalesce(x, 1)))

# create a graph with clean names
# warning due to unhandled mu
Expand Down

0 comments on commit ec3cd3c

Please sign in to comment.