test_that('splitlevel makes a new factor with split level',{
## Success test
x <- data.frame(first = c(1:20), second = rep(c("A","B"), each = 10),
third = rep_len(c("W","X","Y","Z"), 20))
res <- splitlevel(x,"second","A","third", "callitwhatyouwant")
expect_identical( TRUE , all(res["callitwhatyouwant"] ==
c("A_W","A_X","A_Y",
"A_Z","A_W","A_X","A_Y",
"A_Z","A_W","A_X","B","B","B","B","B","B",
"B","B","B","B")))
## Failure test
expect_error(splitlevel(x,"second","A","third", x),
'The input "newfactorname" is not of the class character!')
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.