demoR
demoR copied to clipboard
(this package has been replaced by "flair")
trafficstars
demoR
To get started, please refer to this vignette.
Overview
demoR is a set of tools for formatting R code for presentations, teaching demonstrations, and much more:
-
The
demo_*()functions prepare your source code to be both evaluated and displayed byknitr::knit(). -
The
hlt_*()functions add text display formatting to printed code.
These combine naturally within code chunks in R Markdown files via code chunk options. You can learn more about them in vignette("demoR").
Installation
Development version
Currently, only the development version of demoR is available. You can install this by running
# install.packages("devtools")
devtools::install_github("kbodwin/demoR")
Usage
library(demoR)
data(iris)
codestring <- "mean(iris$Sepal.Length, na.rm = TRUE)"
hlt_funs(codestring)
#> [1] "<pre class='prettyprint'><code><span style='background-color:#ffff7f'>mean</span>(iris$Sepal.Length, na.rm = TRUE)</code></pre>"
hlt_args(codestring)
#> [1] "<pre class='prettyprint'><code>mean(iris$Sepal.Length, <span style='background-color:#ffff7f'>na.rm</span> = TRUE)</code></pre>"
demo_code(codestring) %>% hlt_args()
mean(iris$Sepal.Length, na.rm = TRUE)
#> [1] 5.843333
Getting help
If you encounter a clear bug, please file a minimal reproducible example on github.