library(details)
Using details
in a standard r
chunk is simple. There is a built in print method that handles all the different types of outputs. These methods are shown in the other vignettes. It basically looks like this:
::details({
details<- 1
x * 2
x summary = 'click to see eval') },
1] 2 [
This is nice but leaves a lot of busy work if you want to hide the use of details
in the output.
One chunk to show the code with eval
set to FALSE
<- 1
x * 2 x
Another chunk with echo
set to FALSE
to create the details
output
1] 2 [
When you have multiple chunks in the document it can get very cumbersome and maintance instensive.
To solve this problem there is now a details
chunk engine that will take care of all that work for you.
We add a few chunk options to control the details
output:
Option | Default |
---|---|
details.lang | ‘r’ |
details.summary | NULL |
details.tooltip | ‘Click to Open’ |
details.open | FALSE |
details.imgur | FALSE |
Lets take the same example, this time we will use the details
engine
we evaluate the following chunk
```{details}
x <- 1
x * 2
```
By Default echo = TRUE
will act just like a regular chunk echo and print put what goes into the details
call.
x <- 1
x * 2
1] 2 [
```{details, echo = FALSE, details.summary = 'open to see eval'}
x <- 1
x * 2
```
We can set echo = FALSE
and only return the details output
1] 2 [
We can set the details block to be open by setting the details.open to TRUE
```{details,details.summary = 'click to hide eval',details.open = TRUE}
x <- 1
x * 2
```
x <- 1
x * 2
1] 2 [
We can remove the tooltip by setting details.tooltip
to NULL
```{details,details.summary = 'click to see eval',details.tooltip = NULL}
x <- 1
x * 2
```
x <- 1
x * 2
1] 2 [
We can print out the contents of a file by putting the path in the chunk and control the highlighting language with details.lang
```{details,echo = FALSE, details.lang = '',details.summary = 'open to see contents'}
"../DESCRIPTION"
```
Package: details
Title: Create Details HTML Tag for Markdown and Package
Documentation
Version: 0.3.0
Authors@R:
person(given = "Jonathan",
family = "Sidi",
role = c("aut", "cre"),
email = "yonicd@gmail.com")
Description: Create a details HTML tag around R objects to place
in a Markdown, 'Rmarkdown' and 'roxygen2' documentation.
License: MIT + file LICENSE
URL: https://github.com/yonicd/details
BugReports: https://github.com/yonicd/details/issues
Depends:
R (>= 3.2.0)
Imports:
clipr,
desc,
grid,
httr,
htmltools,
knitr,
magrittr,
png,
stats,
utils,
withr,
xml2
Suggests:
covr,
rmarkdown,
sessioninfo,
testthat,
tibble
VignetteBuilder:
knitr
Encoding: UTF-8
LazyData: false
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
```{details}
plot(1:10,1:10)
```
plot(1:10,1:10)