Skip to content

Commit

Permalink
row_sum() checks
Browse files Browse the repository at this point in the history
ref #126
  • Loading branch information
wibeasley committed Oct 28, 2023
1 parent a0e35dc commit 4457547
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export(update_packages_addin)
export(upload_sqls_odbc)
export(verify_value_headstart)
importFrom(magrittr,"%>%")
importFrom(rlang,":=")
importFrom(rlang,.data)
importFrom(utils,capture.output)
importFrom(utils,installed.packages)
17 changes: 13 additions & 4 deletions R/row.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#' @param threshold_proportion Designates the minimum proportion of columns
#' that have a nonmissing values (within each row) in order to return a sum.
#' Required; defaults to to 0.75.
#' @param vebose a logical value to designate if extra information is
#' @param vv a logical value to designate if extra information is
#' displayed in the console,
#' such as which columns are matched by `pattern`.
#'
Expand All @@ -30,6 +30,7 @@
#'
#' @note
#' @author Will Beasley
#' @importFrom rlang :=
#' @examples
#' library(OuhscMunge) #Load the package into the current R session.

Expand All @@ -41,8 +42,16 @@ row_sum <- function(
pattern,
new_column_name = "row_sum",
threshold_proportion = .75,
verbose = FALSE
vv = FALSE
) {
checkmate::assert_data_frame(d)
checkmate::assert_character(columns_to_average , any.missing = FALSE)
checkmate::assert_character(pattern , min.len = 0, max.len = 1)
checkmate::assert_character(new_column_name , len = 1)
checkmate::assert_double( threshold_proportion, len = 1)
checkmate::assert_logical( vv , len = 1)



if (length(columns_to_average) == 0L) {
columns_to_average <-
Expand All @@ -55,7 +64,7 @@ row_sum <- function(
perl = TRUE
)

if (verbose) {
if (vv) {
message(
"The following columns will be summed:\n- ",
paste(columns_to_average, collapse = "\n- ")
Expand All @@ -72,7 +81,7 @@ row_sum <- function(
}
)

rs <- nonmissing_count <- NULL
rs <- nonmissing_count <- nonmissing_proportion <- NULL
d <-
d |>
dplyr::mutate(
Expand Down
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ lettercase
libcurl
mrn
nonmissing
nonmissingness
odbc
openssl
patientdob
Expand Down
4 changes: 2 additions & 2 deletions man/row_sum.Rd

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

0 comments on commit 4457547

Please sign in to comment.