tests/testthat/test-calcUnique.R

library(calcUnique)


#create a random sample of dates to test on
ts_sample <-
  sample(
    as.character(
      seq(from = as.POSIXct('2020-03-01'), to = as.POSIXct('2020-03-15'), by = 'day')
    ),
    size = 30, replace = TRUE
  )


#just the examples from the documentation ... I can't think of others
expect_equal(calcUnique(ts_sample, as.POSIXct), as.POSIXct(ts_sample))

expect_equal(calcUnique(ts_sample, function(i) gsub("00","$$", i)), gsub("00","$$", ts_sample))

Try the calcUnique package in your browser

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

calcUnique documentation built on May 5, 2020, 1:05 a.m.