Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Dec 7, 2023
1 parent 686579e commit c74f662
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 31 deletions.
2 changes: 1 addition & 1 deletion R/adorn_percentages.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' `data.frame` in the list (designed for 3-way `tabyl` lists).
#' @param denominator The direction to use for calculating percentages.
#' One of "row", "col", or "all".
#' @param na.rm should missing values (including NaN) be omitted from the calculations?
#' @param na.rm should missing values (including `NaN`) be omitted from the calculations?
#' @param ... columns to adorn. This takes a <[`tidy-select`][dplyr::dplyr_tidy_select]>
#' specification. By default, all numeric columns (besides the initial column, if numeric)
#' are adorned, but this allows you to manually specify which columns should
Expand Down
12 changes: 4 additions & 8 deletions R/adorn_title.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,14 @@ adorn_title <- function(dat, placement = "top", row_name, col_name) {

if (inherits(dat, "tabyl")) {
if (attr(dat, "tabyl_type") == "one_way") {
warning(c(
"adorn_title is meant for two-way tabyls, ",
"calling it on a one-way tabyl may not yield a meaningful result"
))
warning(
"adorn_title is meant for two-way tabyls, calling it on a one-way tabyl may not yield a meaningful result"
)
}
}
if (missing(col_name)) {
if (!inherits(dat, "tabyl")) {
stop(c(
"When input is not a data.frame of class tabyl, ",
"a value must be specified for the col_name argument"
))
stop("When input is not a data.frame of class tabyl, a value must be specified for the col_name argument.")
}
col_var <- attr(dat, "var_names")$col
} else {
Expand Down
11 changes: 2 additions & 9 deletions R/adorn_totals.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ adorn_totals <- function(dat, where = "row", fill = "-", na.rm = TRUE, name = "T
}

if (length(cols_to_total) == 0) {
stop(
"at least one targeted column must be of class numeric. ",
"Control target variables with the ... argument. ",
"adorn_totals should be called before other adorn_ functions."
)
stop("at least one targeted column must be of class numeric. Control target variables with the ... argument. adorn_totals should be called before other adorn_ functions.")
}

if (sum(where %in% c("row", "col")) != length(where)) {
Expand Down Expand Up @@ -153,10 +149,7 @@ adorn_totals <- function(dat, where = "row", fill = "-", na.rm = TRUE, name = "T
if (!1 %in% cols_to_total) { # give users the option to total the first column?? Up to them I guess
col_totals[1, 1] <- name[1] # replace first column value with name argument
} else {
message(
"Because the first column was specified to be totaled, ",
"it does not contain the label 'Total' (or user-specified name) in the totals row"
)
message("Because the first column was specified to be totaled, it does not contain the label 'Total' (or user-specified name) in the totals row")
}
dat[(nrow(dat) + 1), ] <- col_totals[1, ] # insert totals_col as last row in dat
if (factor_input) { # restore factor/ordered info, #494
Expand Down
2 changes: 1 addition & 1 deletion R/convert_to_date.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' already. Ignored for Date output.
#' @param ... Passed to further methods. Eventually may be passed to
#' `excel_numeric_to_date()`, `base::as.POSIXct()`, or `base::as.Date()`.
#' @param character_fun A function to convert non-numeric-looking, non-NA values
#' @param character_fun A function to convert non-numeric-looking, non-`NA` values
#' in `x` to POSIXct objects.
#' @param string_conversion_failure If a character value fails to parse into the
#' desired class and instead returns `NA`, should the function return the
Expand Down
4 changes: 2 additions & 2 deletions R/janitor_deprecated.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ add_totals_col <- function(dat, na.rm = TRUE) {
}


#' @title Returns first non-NA value from a set of vectors.
#' @title Returns first non-`NA` value from a set of vectors.
#'
#' @description
#' Warning: Deprecated, do not use in new code. Use [dplyr::coalesce()] instead.
Expand All @@ -107,7 +107,7 @@ add_totals_col <- function(dat, na.rm = TRUE) {
#' It's more readable and handles problems like [ifelse()]'s inability to work with dates in this way.
#'
#' @param ... the input vectors. Order matters: these are searched and prioritized in the order they are supplied.
#' @param if_all_NA what value should be used when all of the vectors return `NA` for a certain index? Default is NA.
#' @param if_all_NA what value should be used when all of the vectors return `NA` for a certain index? Default is `NA`.
#' @return Returns a single vector with the selected values.
#' @seealso janitor_deprecated
#' @export
Expand Down
4 changes: 2 additions & 2 deletions R/make_clean_names.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#'
#' The order of operations is: make replacements, (optional) ASCII conversion,
#' remove initial spaces and punctuation, apply `base::make.names()`,
#' apply `snakecase::to_any_case`, and add numeric suffixes
#' apply `snakecase::to_any_case(()`, and add numeric suffixes
#' to resolve any duplicated names.
#'
#' This function relies on `snakecase::to_any_case` and can take advantage of
#' This function relies on `snakecase::to_any_case()` and can take advantage of
#' its versatility. For instance, an abbreviation like "ID" can have its
#' capitalization preserved by passing the argument `abbreviations = "ID"`.
#' See the documentation for [snakecase::to_any_case()]
Expand Down
2 changes: 1 addition & 1 deletion R/row_to_names.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' @param row_number The row(s) of `dat` containing the variable names or the
#' string `"find_header"` to use `find_header(dat=dat, ...)` to find
#' the row_number. Allows for multiple rows input as a numeric vector. NA's are
#' ignored, and if a column contains only NA value it will be named `"NA"`.
#' ignored, and if a column contains only `NA` value it will be named `"NA"`.
#' @param ... Sent to `find_header()`, if
#' `row_number = "find_header"`. Otherwise, ignored.
#' @param remove_row Should the row `row_number` be removed from the
Expand Down
2 changes: 1 addition & 1 deletion man/adorn_percentages.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/convert_to_date.Rd

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

4 changes: 2 additions & 2 deletions man/make_clean_names.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/row_to_names.Rd

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

4 changes: 2 additions & 2 deletions man/use_first_valid_of.Rd

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

0 comments on commit c74f662

Please sign in to comment.