This commit is contained in:
@@ -158,7 +158,7 @@ race_short_names <- function(x) {
|
|||||||
#' na_sum(x) # 15
|
#' na_sum(x) # 15
|
||||||
na_sum <- function(x) {
|
na_sum <- function(x) {
|
||||||
stopifnot(is.numeric(x))
|
stopifnot(is.numeric(x))
|
||||||
message("Taking a sum with missing values equal to 0, be careful! \u1F601")
|
message("Taking a sum with missing values equal to 0, be careful!")
|
||||||
x <- na_zero(x)
|
x <- na_zero(x)
|
||||||
return(sum(x))
|
return(sum(x))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ test_that("Function subs out NAs in numeric vectors with 0", {
|
|||||||
# Test that na_sum works
|
# Test that na_sum works
|
||||||
test_that("NA Sum takes sum setting NA values to 0", {
|
test_that("NA Sum takes sum setting NA values to 0", {
|
||||||
expect_equivalent(na_sum(c(1:10, NA)), sum(1:10, 0))
|
expect_equivalent(na_sum(c(1:10, NA)), sum(1:10, 0))
|
||||||
expect_message(na_sum(c(1:10, NA)), "Taking a sum with missing values equal to 0, be careful! \u1F601")
|
expect_message(na_sum(c(1:10, NA)), "Taking a sum with missing values equal to 0, be careful!")
|
||||||
})
|
})
|
||||||
|
|
||||||
test_that("na_sum fails with non-numerics", {
|
test_that("na_sum fails with non-numerics", {
|
||||||
|
|||||||
Reference in New Issue
Block a user