tests/testthat/test-fast_factor.R

library(Kmisc)
library(testthat)
set.seed(123)

n <- 1E4

## integer
gp <- sample( n, replace=TRUE )
expect_identical( factor(gp), factor_(gp) )

gp[ sample(length(gp), 1E1) ] <- NA
expect_identical( factor(gp), factor_(gp) )

## character
gp <- sample( letters, n, replace=TRUE )
expect_identical( factor(gp), factor_(gp) )

gp[ sample(length(gp), 1E1) ] <- NA
expect_identical( factor(gp), factor_(gp) )

## logical
gp <- sample( c(TRUE, FALSE), n, TRUE )
expect_identical( factor(gp), factor_(gp) )

gp[ sample(length(gp), 1E1) ] <- NA
expect_identical( factor(gp), factor_(gp) )

Try the Kmisc package in your browser

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

Kmisc documentation built on May 29, 2017, 1:43 p.m.