tests/testthat/test-grouped_shuffler.R

test_that("GroupedShuffler tests",{
  
  frm <- data.frame(A = letters, B = rnorm(26))
  
  grps <- GroupedShuffler$new(A) 
    
  expect_equal(grps$str(), "GroupedShuffler(group_on=A)")
  
  new.data <- grps$mutate(frm, B)
  expect_true(all(
    new.data$B == frm$B
  ))
    
  grps <- GroupedShuffler$new(A, limit=1) 
  new.data <- grps$mutate(frm, B)
  
  expect_true(all(
    is.na(new.data$B)
  ))

})

Try the deident package in your browser

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

deident documentation built on April 3, 2025, 6:14 p.m.