tests/testthat/test_bootstrap.R

context("Testing bootstrap.R")

test_that("test stratSample", {
  f <- as.factor(c(1,1,1,2,4,4,4,4,6,6)) # contains also a stratum with only one entry -> important  to check sample!

  expect_error(stratSample(c(1,2,2,1,45)), "f has to be a factor variable.")
  
  for(i in 1:10) # repeat sampling 10 times
    expect_equal(table(f, dnn = NULL), table(f[stratSample(f)], dnn = NULL)) # dnn: no names for variable that is 'tabled'
})

Try the MFPCA package in your browser

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

MFPCA documentation built on Sept. 15, 2022, 9:07 a.m.