test_that("mutate and transmute", {
ir = as.data.table(iris)
expect_equal(
iris %>% mutate_dt(one = 1,Sepal.Length = Sepal.Length + 1),
copy(ir)[,`:=`(one = 1,Sepal.Length = Sepal.Length + 1)]
)
expect_equal(
iris %>% mutate_dt(id = 1:.N,grp = .GRP,by = Species),
copy(ir)[,`:=`(id = 1:.N,grp = .GRP),by = Species]
)
expect_equal(
iris %>% transmute_dt(one = 1,Sepal.Length = Sepal.Length + 1),
ir[,.(one = 1,Sepal.Length = Sepal.Length + 1)]
)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.