tests/testthat/test-Tapply.R

library(functools)
context("Tapply()")

groups <- as.factor(rbinom(size = 32, n = 10000, prob = 0.1))
n <- 17; fac <- factor(rep(1:3, length = n), levels = 1:5)

test_that("Produces the correct output.", {
  expect_equal(Tapply(groups, groups, .f = length), tapply(groups, groups, length))
})

test_that("Produces the correct output type.", {
  expect_is(Tapply(groups, groups, .f = length), "array")
})

test_that("Produces the correct errors.", {
  expect_error(Tapply(length, groups, groups))
})

Try the functools package in your browser

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

functools documentation built on May 2, 2019, 5:39 a.m.