The tab titles are names of list members, and the tab content contains the values of list members. If a list member is also a list, it will be represented recursively with a child tabset.
Arguments
- x
A list for
tabset(), and a character vector fortab_content().- value
A function to print the value of a list member. By default,
str()is used to print the structure of the value. You may also usedput()to output the full value, but it may be slow when the size of the value is too big. If the function prints the value to the console, the output will be captured and shown in a code block. If you want construct the tab content by yourself instead of capturing console output as a code block, you may pass the Markdown content totab_content()and return it in thisvalue()function.
Value
A character vector of Markdown that can be rendered to HTML with
litedown::mark().
Examples
xfun::tabset(iris)
xfun::tabset(iris, dput)
xfun::tabset(iris, print)
# a deeply nested list
plot(1:10)
p = recordPlot()
xfun::tabset(p)
# custom tab content
xfun::tabset(iris, function(x) {
if (is.factor(x)) {
res = c("A factor with levels: ", xfun::join_words(levels(x), before = "`"))
xfun::tab_content(res)
} else print(summary(x))
})