inst/tinytest/test_coalesce.R

cat("\nContext:","coalesce", "\n")
suppressPackageStartupMessages(library(maditr))
x = c(1, NA, 2, NA)
res = coalesce(x, 0)
expect_equal( res, c(1, 0, 2, 0))
expect_error(coalesce(x, 1:2))

y = c(1, 2, NA, NA, 5)
z = c(NA, NA, 3, 4, 5)
expect_equal(coalesce(y, z), 1:5)

Try the maditr package in your browser

Any scripts or data that you put into this service are public.

maditr documentation built on April 2, 2022, 5:05 p.m.