tests/testthat/test-colwise-distinct.R

context("colwise distinct")

test_that("scoped distinct is identical to manual distinct", {
  df <- data_frame(
    x = rep(2:5, each=2),
    y = rep(2:3, each = 4),
    z = "a"
  )

  expect_identical(distinct_all(df), distinct(df, x, y, z))
  expect_identical(distinct_at(df, vars(x)), distinct(df, x))
  expect_identical(distinct_if(df, is.integer), distinct(df, x, y))
})

test_that(".funs is applied to variables before getting distinct rows", {
  df <- data_frame(
    x = rep(2:5, each=2),
    y = rep(2:3, each = 4)
  )

  expect_identical(distinct_all(df, `-`), distinct(mutate_all(df,`-`), x, y))
})
olascodgreat/samife documentation built on May 13, 2019, 6:11 p.m.