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)

})

Related questions

0 votes
asked Jun 15, 2023 in R Basics by john ganales
+1 vote
asked Jan 30, 2022 in R Basics by GeorgeBell
...