| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/markdown.R |
| 3 |
\name{tabset} |
| 4 |
\alias{tabset} |
| 5 |
\alias{tab_content} |
| 6 |
\title{Represent a (recursive) list with (nested) tabsets} |
| 7 |
\usage{ |
| 8 |
tabset(x, value = str) |
| 9 |
|
| 10 |
tab_content(x) |
| 11 |
} |
| 12 |
\arguments{ |
| 13 |
\item{x}{A list for \code{tabset()}, and a character vector for \code{tab_content()}.} |
| 14 |
|
| 15 |
\item{value}{A function to print the value of a list member. By default, |
| 16 |
\code{\link[=str]{str()}} is used to print the structure of the value. You may also use |
| 17 |
\code{\link[=dput]{dput()}} to output the full value, but it may be slow when the size of the |
| 18 |
value is too big. If the function prints the value to the console, the |
| 19 |
output will be captured and shown in a code block. If you want construct |
| 20 |
the tab content by yourself instead of capturing console output as a code |
| 21 |
block, you may pass the Markdown content to \code{\link[=tab_content]{tab_content()}} and return it |
| 22 |
in this \code{value()} function.} |
| 23 |
} |
| 24 |
\value{ |
| 25 |
A character vector of Markdown that can be rendered to HTML with |
| 26 |
\code{\link[litedown:mark]{litedown::mark()}}. |
| 27 |
} |
| 28 |
\description{ |
| 29 |
The tab titles are names of list members, and the tab content contains the |
| 30 |
values of list members. If a list member is also a list, it will be |
| 31 |
represented recursively with a child tabset. |
| 32 |
} |
| 33 |
\examples{ |
| 34 |
xfun::tabset(iris) |
| 35 |
xfun::tabset(iris, dput) |
| 36 |
xfun::tabset(iris, print) |
| 37 |
|
| 38 |
# a deeply nested list |
| 39 |
plot(1:10) |
| 40 |
p = recordPlot() |
| 41 |
xfun::tabset(p) |
| 42 |
|
| 43 |
# custom tab content |
| 44 |
xfun::tabset(iris, function(x) { |
| 45 |
if (is.factor(x)) { |
| 46 |
res = c("A factor with levels: ", xfun::join_words(levels(x), before = "`")) |
| 47 |
xfun::tab_content(res) |
| 48 |
} else print(summary(x)) |
| 49 |
}) |
| 50 |
} |