Create HTML DOM Details block for Markdown documents with summary as optional.
details(object, ..., summary = NULL, tooltip = "Click to Expand", open = FALSE, lang = "r", output = c("console", "clipr", "edit", "character"), imgur = TRUE, comment = NA)
object | object, object to put in details block |
---|---|
... | arguments to pass to print method of the object |
summary | character, text to put in summary block, Default: NULL |
tooltip | character, text for tooltip on the summary, Default: 'Click to Expand' |
open | logical, is the details open (TRUE) or closed (FALSE), Default: FALSE |
lang | character, language of block (for markdown highlighting) Default: 'r' |
output | character, where to output the file console (Default), clipboard or R file editor, Default: c('console','clipr','file.edit','character') |
imgur | logical, upload device outputs to imgur, Default: TRUE |
comment | character, the prefix to be put before source code output, Default: NA |
character
To remove summary or tooltip set them to NULL. If the object is a file path, it will automatically it's lines will be read in internally.
If lang is NULL then the output will not be wrapped in a code block and will display the raw output (useful for HTML)
When using details in knitr/rmarkdown documents there is no need to set the results to 'asis', there are already predefined print methods for these environments.
... is passed to objects that do not invoke an image device.
#> <details closed> #> #> ```r #> #> test #> #> ``` #> #> </details> #> <br>#> <details closed> #> <summary> <span title='Click to Expand'> sessionInfo </span> </summary> #> #> ```r #> #> R version 3.6.3 (2020-02-29) #> Platform: x86_64-apple-darwin15.6.0 (64-bit) #> Running under: macOS Catalina 10.15.7 #> #> Matrix products: default #> BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib #> LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib #> #> locale: #> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 #> #> attached base packages: #> [1] stats graphics grDevices utils datasets methods base #> #> other attached packages: #> [1] details_0.2.2 #> #> loaded via a namespace (and not attached): #> [1] compiler_3.6.3 pillar_1.4.7 prettyunits_1.1.1 remotes_2.2.0 #> [5] tools_3.6.3 highlight_0.5.0 digest_0.6.27 pkgbuild_1.2.0 #> [9] jsonlite_1.7.2 memoise_1.1.0 evaluate_0.14 lifecycle_0.2.0 #> [13] tibble_3.0.4 png_0.1-7 pkgconfig_2.0.3 rlang_0.4.10 #> [17] cli_2.2.0 rstudioapi_0.13 curl_4.3 yaml_2.2.1 #> [21] pkgdown_1.4.1.9000 xfun_0.20 xml2_1.3.2 withr_2.3.0 #> [25] httr_1.4.2 knitr_1.30 askpass_1.1 desc_1.2.0 #> [29] fs_1.5.0 vctrs_0.3.6 grid_3.6.3 rprojroot_2.0.2 #> [33] glue_1.4.2 R6_2.5.0 processx_3.4.5 fansi_0.4.1 #> [37] rmarkdown_2.6 whisker_0.4 clipr_0.7.1 callr_3.5.1 #> [41] purrr_0.3.4 magrittr_2.0.1 rematch2_2.1.2 ps_1.5.0 #> [45] ellipsis_0.3.1 htmltools_0.5.1 MASS_7.3-51.5 assertthat_0.2.1 #> [49] openssl_1.4.3 crayon_1.3.4 #> #> ``` #> #> </details> #> <br>#> <details closed> #> #> ```r #> #> mpg cyl disp hp drat wt qsec vs am gear carb #> Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4 #> Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4 #> Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1 #> Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1 #> Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2 #> Valiant 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1 #> #> ``` #> #> </details> #> <br>#> <details closed> #> <summary> <span title='Click to Expand'> Plots </span> </summary> #> #> ![](https://i.imgur.com/CI8kA1v.png) #> #> </details> #> <br>#> [1] "<details closed>" "" "```r" "" #> [5] "test" "" "```" "" #> [9] "</details>" "<br>"#clipboard if(clipr::clipr_available()){ details::details('test', output = 'clipr') clipr::read_clip() } #file.edit # \donttest{ details::details('test', output = 'edit')#> Warning: Not an interactive enviornment, falling back to output = "console"#> <details closed> #> #> ```r #> #> test #> #> ``` #> #> </details> #> <br># }