tests/testthat/test-cutnumeric.R

context("cutnumeric")

test_that("cutnumeric works", {
  set.seed(20150605)
  x <- rnorm(50)
  xclass <- cut(x, seq( min(x), max(x), length = 1000 ), include.lowest = TRUE )
  
  y <- unlist( lapply( xclass, function(b) {
    h <- strsplit( as.character(b), "," )[[1]]
    h <- as.numeric(gsub( "\\[", "", 
                          gsub("\\]", "", gsub("\\(", "", h ) ) ))
    mean( h )
  } ) )
  expect_equal( cutnumeric(x), y)
})
masspastore/overlapping documentation built on Oct. 18, 2019, 3:31 a.m.