tests/testthat/test_spl.R

test_that("works as expected", {
  
  expect_equal( nrow(spl(cars,10)), 10 )
  expect_equal( all(c('speed','dist') %in% colnames(spl(cars,30))), T )
  expect_equal( nrow( spl( iris ) ) > 0, TRUE )
  expect_equal( length( spl( c(1:100), 50 ) ), 50 )
  expect_equal( suppressWarnings( length( spl( c(1:100), 200 ) ) ), 100 )

  expect_equal( nrow( spl( cars, 0.1 ) ), ceiling( 0.1 * nrow(cars) ) )
  expect_equal( length( spl( cars$speed, 0.1 ) ), ceiling( 0.1 * nrow(cars) ) )
  
  expect_warning( spl( cars, 60 ), '[60]' )
  expect_warning( spl( cars$speed, 60 ), '[60]' )
  
  set.seed(123)
  t = spl(mtcars)
  expect_equal(t, spl(mtcars, seed = 123))
  
})

Try the easyr package in your browser

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

easyr documentation built on March 31, 2023, 6:22 p.m.