tests/testthat/test_outputs_functions.R

library(optinterv)

set.seed(223)

#create data
var <- rnorm(1000)
w <- sample(c(1,2,3), 1000, replace = T)

test_that("the mean of all bins is the same as the overall mean", {
  expect_equal(mean(wtd_bin(var, 30, w)), weighted.mean(var, w))
})

test_that("the mean of one quantile is the same as the overall mean", {
  expect_equal(wtd_bin(var, 1, w), weighted.mean(var, w))
})

Try the optinterv package in your browser

Any scripts or data that you put into this service are public.

optinterv documentation built on March 26, 2020, 7:05 p.m.