context("compose2") # CONTEXT, one y file
#library(compose2)
library(testthat)
test_that(".from_right parameter works as it should", {
expect_identical(compose2(~head(.,1),dim, .from_right = TRUE)(iris), head(dim(iris),1))
expect_identical(compose2(~head(.,1),dim, .from_right = FALSE)(iris), dim(head(iris,1)))
})
test_that("compose2 supports different notations", {
expect_identical(compose2(dim,head)(iris) , head(dim(iris)))
expect_identical(compose2(~dim(.),~head(.,1))(iris), head(dim(iris),1))
expect_identical(compose2(dim, head=2)(iris) , head(dim(iris),2))
expect_identical(compose2(dim, head=c(n=2))(iris) , head(dim(iris),2))
expect_identical(compose2(dim, head=list(n=2))(iris) , head(dim(iris),2))
expect_identical(compose2(dim, head=list(n=2))(iris) , head(dim(iris),2))
expect_identical(compose2(~head(.,1),dim, .from_right = FALSE)(iris), dim(head(iris,1)))
})
test_that("global arguments work with all notations", {
expect_identical(compose2(dim, head, .args = c(n = 2))(iris) , head(dim(iris),2))
expect_identical(compose2(head, dim, .args = c(n = 2))(iris) , dim(head(iris,2)))
expect_identical(compose2(~head(.), dim, .args = c(n = 2))(iris), dim(head(iris)))
expect_identical(compose2(~head(., ...), dim, .args = c(n = 2))(iris), dim(head(iris,2)))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.