0 votes
in R Basics by
How do you test R code? Can you write a test for the function you wrote in #6?

1 Answer

0 votes
by
You can use Hadley's testthat package. A test might look like this:

testthat("It imputes the median correctly", {

  expect_equal(mean_impute(c(1, 2, NA, 6)), 3)

})
...