It has been one year since my last article, and here is a quick post indicating that my blog is not down. Instead, it has a new look thanks to blogdown. Yes, pun intended. :-) blogdown, mostly written by Yihui, is an R package that can help you rapidly create a static blog or website. The package name has nothing to do with the status of a website (as in “the server is down”), but rather follows the convention of other Markdown-based packages such as rmarkdown and bookdown.
Have you ever tried to find a lightweight yet nice theme for the R Markdown documents, like this page? Themes for R Markdown With the powerful rmarkdown package, we could easily create nice HTML document by adding some meta information in the header, for example --- title: Nineteen Years Later author: Harry Potter date: July 31, 2016 output: rmarkdown::html_document: theme: lumen --- The html_document engine uses the Bootswatch theme library to support different styles of the document.
Thanks to the issue report by yufree and Yihui’s kind work, from version 1.6.10 (development version), knitr starts to support using showtext to change fonts in R plots. To demonstrate its usage, this document itself serves as an example. (Rmd source code) We first do some setup work, mainly about setting options that control the appearance of the plots. Notice that if you create plots in PNG format (the default format for HTML output), it is strongly recommended to use the CairoPNG device rather than the default png, since the latter one could produce quite ugly plots when using showtext.