context("force_categorical")
library(magrittr)
library(tibble)
library(testthat)
rm(list = ls())
set.seed(0)
numcol <- 1:10 %>% as.numeric()
intcol <- numcol %>% as.integer()
#### parameters invalid on its face ####
# bad df
expect_error(
NULL %>%
force_categorical(),
"variables %>% is.tibble()",
fixed = T)
# bad columns
expect_error(
data.frame(
a = numcol,
b = intcol) %>%
identify_variables() %>%
force_categorical(NULL),
"columns %>% is.vector()",
fixed = T)
#### normal analysis ####
# normal identify
actual <-
data.frame(
a = numcol,
b = intcol) %>%
identify_variables() %>%
force_categorical("b")
expected <-
tibble(
name = c("a", "b"),
class = c("numeric", "integer"),
type = c("continuous", "categorical"))
expect_equal(actual, expected)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.