library(rutilities)
library(tibble)
context("Checking print and capture")
test_that("Checking that print and capture returns correctly",{
# Easy stuff
expect_identical(print_and_capture(1), "[1] 1")
expect_identical(print_and_capture("a"), "[1] \"a\"")
expect_identical(print_and_capture(c("a", "b")), "[1] \"a\" \"b\"")
# Data frames
expect_identical(print_and_capture(tibble::tibble(x = c("a", "b"))),
"# A tibble: 2 x 1\n x\n <chr>\n1 a\n2 b")
# Lists
expect_identical(print_and_capture(list(x = c("a", "b"))),
"$x\n[1] \"a\" \"b\"\n")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.