Note that because this demonstration uses rmarkdown::html_document()
, we can use Bootstrap classes to customize the chunk outputs.
# setup
knitr::opts_chunk$set(
class.output = "bg-success",
class.message = "bg-info text-info",
class.warning = "bg-warning text-warning",
class.error = "bg-danger text-danger"
)
paste("Normal", "R chunk", "output!!")
## [1] "Normal R chunk output!!"
message("This is a message")
## This is a message
warning("This is a warning")
## Warning: This is a warning
stop("An error occurred in this chunk.", call. = FALSE)
## Error: An error occurred in this chunk.