These are useful knitr options for starting an R Markdown document:

library(knitr)
knitr::opts_chunk$set(message=FALSE, warning = FALSE) # echo = FALSE
options(scipen = 999, digits = 2)

I always got wrong that digits is in options() and not opts_chunk$set(). The option scipen = 999 disables the horrible scientific number printing.

Don’t forget to include the following in the YAML header to ensure that data frames are printed nicely:

output:
  html_document:
    df_print: kable

Last updated: 2019-11-27

Back to the front page