tests/testthat/test-get_colums_by_type.R

test_that("can find date columns", {
  d <- data.frame(
    date = c(lubridate::ymd("2018-01-01"), lubridate::ymd("2018-01-02")),
    number = c(1, 2)
  )

  cols <- get_columns_by_type_match(d, lubridate::is.Date)

  expect_equal(cols, c("date"))
})

test_that("can find numeric columns", {
  d <- data.frame(
    date = c(lubridate::ymd("2018-01-01"), lubridate::ymd("2018-01-02")),
    number = c(1, 2)
  )

  cols <- get_columns_by_type_match(d, is.numeric)

  expect_equal(cols, c("number"))
})

Try the tsviz package in your browser

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

tsviz documentation built on July 26, 2019, 5:03 p.m.