Knitr Chunk Engine

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(details)

r chunk engine

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({
  x <- 1
  x * 2
},summary = 'click to see eval')

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

  x <- 1
  x * 2

Another chunk with echo set to FALSE to create the details output

details::details({
  x <- 1
  x * 2
},summary = 'click to see eval')

When you have multiple chunks in the document it can get very cumbersome and maintance instensive.

details chunk engine

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

Default

we evaluate the following chunk

`r ''````{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.

Output

x <- 1
x * 2

Without Echo

`r ''````{details, echo = FALSE, details.summary = 'open to see eval'}
x <- 1
x * 2
```

We can set echo = FALSE and only return the details output

Output

```{details, echo = FALSE, details.summary = 'open to see eval'} x <- 1 x * 2

## Open with Echo

We can set the details block to be open by setting the details.open to `TRUE`

````markdown
`r ''````{details,details.summary = 'click to hide eval',details.open = TRUE}
x <- 1
x * 2
### Output

```{details,details.summary = 'click to hide eval',details.open = TRUE}
x <- 1
x * 2
```

## Tooltip

We can remove the tooltip by setting `details.tooltip` to NULL

````markdown
`r ''````{details,details.summary = 'click to see eval',details.tooltip = NULL}
x <- 1
x * 2
```

Output

```{details,details.summary = 'click to see eval',details.tooltip = NULL} x <- 1 x * 2

## file contents with no highlighting

We can print out the contents of a file by putting the path in the chunk and control the highlighting language with `details.lang`

````markdown
`r ''````{details,echo = FALSE, details.lang = '',details.summary = 'open to see contents'}
"../DESCRIPTION"
### Output

```{details,echo = FALSE, details.lang = '',details.summary = 'open to see contents'}
'../DESCRIPTION'
```

## Figures


````markdown
`r ''````{details}
plot(1:10,1:10)
```

Output

plot(1:10,1:10)


Try the details package in your browser

Any scripts or data that you put into this service are public.

details documentation built on March 28, 2022, 1:06 a.m.