context("coalesce")
require(fql)
test_that("idempotent when no NA", {
expect_equal(0 %^% 1:2, 1:2)
})
test_that("replace all NA", {
expect_equal(0 %^% rep(NA, 2), rep(0, 2))
})
test_that("replace NA at back", {
expect_equal(0 %^% c(1, NA), c(1, 0))
})
test_that("replace random NA", {
x <- 10 %?% c(NA, 1)
y <- x
x[is.na(x)] <- 0
expect_equal(0 %^% y, x)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.