Expectation checking whether values from a given sample have a certain mean or that two samples have the same mean. The underlying procedure is Student's t-test
The expectation throws an error when the test's p-value is smaller than the threshold p-value.
threshold p-value of the test
parameters to pass to t.test function including data sample(s)
Invisibly returns a p-value of the test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# This test doesn't pass ## Not run: x<-1:1e3 expect_mean_equal(x=x) ## End(Not run) # This one passes, but shouldn't x<-rnorm(1e3) + 0.01 expect_mean_equal(x=x) x<-rnorm(1e3) expect_mean_equal(x=x) # check if 2 samples have the same mean x<-rnorm(1e3, mean=10) y<-rnorm(1e3, mean=10) expect_mean_equal(x=x, y=y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.