tests/testthat/test-summarise.r

context("Summarise")

test_that("summarise creates correct names", {
  df <- summarise(mtcars, cyl, vs)
  expect_that(names(df), equals(c("cyl", "vs")))

  df <- summarise(mtcars, x = cyl, vs)
  expect_that(names(df), equals(c("x", "vs")))

  df <- summarise(mtcars, x = cyl, y = vs)
  expect_that(names(df), equals(c("x", "y")))

  df <- summarise(mtcars, mean(cyl), mvs = mean(vs))
  expect_that(names(df), equals(c("mean(cyl)", "mvs")))

})

Try the plyr package in your browser

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

plyr documentation built on Oct. 2, 2023, 9:07 a.m.