context("unit test for TableProfiler methods")
# find_col_types ---------------------------------------------------------------
test_that("find_col_types captures the table col types correctly", {
# Numeric vars
expected_output <-
matrix(rep("numeric", ncol(mtcars)), ncol = ncol(mtcars)) %>%
data.frame(stringsAsFactors = FALSE) %>%
stats::setNames(names(mtcars))
expect_identical(
.find_col_types(.data = mtcars),
expected_output
)
# Dates vars
date <- data.frame(Timestamp = seq.Date(Sys.Date(), Sys.Date()+7, 1))
expect_identical(
.find_col_types(.data = date),
data.frame(Timestamp = "date", stringsAsFactors = FALSE)
)
# Date-Time vars
timestamp <- data.frame(Timestamp = seq.POSIXt(Sys.time(), Sys.time()+7, 1))
expect_identical(
.find_col_types(.data = timestamp),
data.frame(Timestamp = "dttm", stringsAsFactors = FALSE)
)
# Time vars
time <- data.frame(Timestamp = lubridate::hms("12:57:50"))
expect_identical(
.find_col_types(.data = time),
data.frame(Timestamp = "time", stringsAsFactors = FALSE)
)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.