tests/testthat/test_pctile.R

library(dplyr)
library(stringr)
library(statar)
context("pctile")

x <- c(NA, 1:10)                   
test_that("pctile", {
expect_equal(xtile(x, n = 3),  c(NA, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3))
expect_equal(xtile(x, probs = c(0.3, 0.7)), c(NA, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3))
expect_equal(xtile(x, cutpoints = c(2, 3)),  c(NA, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3))
})

Try the statar package in your browser

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

statar documentation built on Aug. 19, 2023, 5:09 p.m.