context("pngroup")
test_that("pngroup works", {
expect_null(pngroup(NULL, "a", 1))
expect_null(pngroup("a", NULL, 1))
expect_null(pngroup("a", "a", NULL))
expect_null(pngroup("a", "a", NULL))
expect_identical(pngroup("a", "a"), "a")
expect_identical(pngroup("one two three", ".+\\s.+\\s.+", 1), "one two three")
expect_identical(pngroup("one two three", ".+\\s.+\\s(.+)", 1), "one two three")
expect_identical(pngroup("one two three", "(.+)\\s(.+)\\s(.+)", 4), "three")
expect_identical(pngroup(c("one two three", "four five six"),
"(.+)\\s(.+)\\s(.+)", 2),
c("one", "four"))
expect_identical(pngroup(c("one two three", "four five six"),
"(.+)\\s(.+)\\s(.+)", 2:4),
c("one", "five", "three"))
expect_identical(pngroup("one two three",
c("(.+)\\s(.+)\\s(.+)", ".+\\s.+\\s.+"), 2),
c("one", NA))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.