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)
})
Related questions
0
votes
Q: Can you write me a function in R that replaces all missing values of a vector with the mean of that vector?
asked
Jun 15, 2023
in
R Basics
by
john ganales
rreplaces
0
votes
Q: I want to know all the values in c(1, 4, 5, 9, 10) that are not in c(1, 5, 10, 11, 13). How do I do that with one built-in function in R? How could I do it if that function didn't exist?
asked
Jun 15, 2023
in
R Basics
by
john ganales
-function
0
votes
Q: Explain what is With () and By () function in R is used for?
asked
Feb 22, 2023
in
R Basics
by
SakshiSharma
with-function
by-function
+3
votes
Q: Write code to build an R function powered by C?
asked
Jul 28, 2019
in
R Language
by
Aarav2017
#r-language
#r-programming
#r-course
#r-tutorial
#r-question-answer
#r-interview-question
#r-basics
#r-test
#what-is-r
#learn-r
0
votes
Q: If I execute the expression x <- 4 in R, what is the class of the object 'x' as determined by the `class()' function?
asked
Jun 15, 2023
in
R Basics
by
john ganales
r-expression
0
votes
Q: List out some of the function that R provides?
asked
Feb 22, 2023
in
R Basics
by
SakshiSharma
r-functions
+3
votes
Q: How can you debug and test R programming code?
asked
Jul 28, 2019
in
R Language
by
Aarav2017
#r-language
#r-programming
#r-course
#r-tutorial
#r-question-answer
#r-interview-question
#r-basics
#r-test
#what-is-r
#learn-r
0
votes
Q: How can you save your data in R?
asked
Feb 22, 2023
in
R Basics
by
SakshiSharma
r-data
0
votes
Q: In R how you can import Data?
asked
Feb 22, 2023
in
R Basics
by
SakshiSharma
r-input-data
+1
vote
Q: How i can fit a rational funtion in r?
asked
Jan 30, 2022
in
R Basics
by
GeorgeBell
r-basics
...