Home
Recent Q&A
Java
Cloud
JavaScript
Python
SQL
PHP
HTML
C++
Data Science
DBMS
Devops
Hadoop
Machine Learning
Azure
Blockchain
Devops
Ask a Question
How do you test R code? Can you write a test for the function you wrote in #6?
Home
R Basics
How do you test R code? Can you write a test for the function you wrote in #6?
0
votes
asked
Jun 15, 2023
in
R Basics
by
john ganales
How do you test R code? Can you write a test for the function you wrote in #6?
rcode
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
Jun 15, 2023
by
john ganales
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)
})
...