tests/testthat/test-stylest2_select_vocab.R

library(stylest2)
library(quanteda)

novels_dfm <- dfm(tokens( data(novels) ))

test_that('invalid nfolds raises error', {
  expect_error(stylest2_select_vocab(dfm = novels_dfm, nfold = 0),
               'nfold must be at least 1')
  expect_error(stylest2_select_vocab(dfm = novels_dfm, nfold = 1.5),
               'nfold must be an integer')
  }
)

test_that('invalid cutoff pct raises error', {
  expect_error(stylest2_select_vocab(dfm = novels_dfm, cutoffs = c(-50, 100)),
               'all values in cutoffs must be between 0 and 100')
  }
)

Try the stylest2 package in your browser

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

stylest2 documentation built on May 29, 2024, 1:50 a.m.