Nothing
# Create a shortened version of `iris`
iris_short <- iris[1:5, ]
test_that("The `tab_spanner_delim()` function works correctly", {
# Create a `tbl_latex` object with `gt()`; split the column
# names into spanner headings and column labels
tbl_latex <-
gt(iris_short) %>%
tab_spanner_delim(delim = ".")
# Expect a characteristic pattern
expect_match(
as_latex(tbl_latex) %>% as.character(),
paste0(
".*multicolumn\\{2\\}\\{c\\}\\{Sepal\\}.*multicolumn\\{2\\}\\{c\\}\\{Petal\\}",
".*cmidrule\\(lr\\)\\{1-2\\}.*cmidrule\\(lr\\)\\{3-4\\}",
".*Length & Width & Length & Width & Species.*"
)
)
# Create a `tbl_latex` object with `gt()`; split the column
# names into spanner headings and column labels but constrain
# the splitting only to the `Sepal.Length` and `Sepal.Width` columns
tbl_latex <-
gt(iris_short) %>%
tab_spanner_delim(
delim = ".",
columns = c("Sepal.Length", "Sepal.Width")
)
# Expect a characteristic pattern
expect_match(
as_latex(tbl_latex) %>% as.character(),
paste0(
".*multicolumn\\{2\\}\\{c\\}\\{Sepal\\} & & & .*",
".cmidrule\\(lr\\)\\{1-2\\}.*",
"Length & Width & Petal.Length & Petal.Width & Species.*"
)
)
# Create a `tbl_latex` object with `gt()`; split the column
# names into spanner headings and column labels but constrain
# the splitting only to the `Sepal.Length` and `Sepal.Width`
# columns using `c()`
tbl_latex <-
gt(iris_short) %>%
tab_spanner_delim(
delim = ".",
columns = c(Sepal.Length, Sepal.Width)
)
# Expect a characteristic pattern
expect_match(
as_latex(tbl_latex) %>% as.character(),
paste0(
".*multicolumn\\{2\\}\\{c\\}\\{Sepal\\} & & & .*",
".cmidrule\\(lr\\)\\{1-2\\}.*",
"Length & Width & Petal.Length & Petal.Width & Species.*"
)
)
})
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.