context('new_variable')
test_that('it can make a new column', {
iris2 <- iris
new_variable(
iris2,
function(Sepal.Width, Sepal.Length) Sepal.Width*2 + Sepal.Length*2,
'Sepal.Perimeter'
)
expect_equal(
iris2$Sepal.Perimeter,
iris$Sepal.Width*2 + iris$Sepal.Length*2
)
})
test_that('it can make a new column without a function', {
iris2 <- iris
new_variable(iris2, iris$Sepal.Width*2, 'Sepal.Width2')
expect_equal(iris2$Sepal.Width2, iris$Sepal.Width*2)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.