Yihui's Blog
2,300 FOLLOWERS
Yihui Xie is a software engineer at RStudio. As an active R user, he has authored several R packages, such as knitr, bookdown, blogdown, xaringan, animation, DT, tinytex, tufte, formatR, fun, mime, highr, servr, Rd2roxygen and much more. He has also initiated the Chinese R conference in 2008, and has been involved in organizing R conferences in China since then. Follow this blog where Yihui..
Yihui's Blog
11M ago
Who is down? Me. After more than 10 years at RStudio/Posit, the time has come for me to explore other opportunities. A little over two weeks ago, I was told that I was laid off and my last day would be 2023-12-31. Frankly speaking, I was quite surprised but only for a short moment. I fully respected Posit’s decision, and quickly accepted the conclusion that my contribution no longer deserved a full-time job here. The end of a relationship often does not imply anything wrong or a failure of either party. Instead, it can simply indicate a mismatch, which is normal. People just change. With these ..read more
Yihui's Blog
1y ago
Three years ago, Xianying Tan helped me add the SearchBuilder extension of DataTables to the DT package. This extension did not exist when I first started developing DT, otherwise I would not have spent countless hours on creating a variety of filters in DT by myself and make them work in both the client and server modes. This extension is much, much more flexible than my clumsy “homemade” filters.
Yes, SearchBuilder has been made available to DT three years ago, but the problem is that it only works on the client side. That is, if you render a table in Shiny, you cannot DT::renderDT(server ..read more
Yihui's Blog
1y ago
Since about a month ago, I have been receiving error reports from TinyTeX users saying “TinyTeX\bin\windows\runscript.tlu:864: no appropriate script or program found: fmtutil” or “I can't find the format file `pdflatex.fmt'!”, which I do not understand.
For the last few days, I scratched my head, banged against the wall, did some research, asked R and LaTeX experts in mailing lists, got reminded of “[[alternative HTML version deleted]]” again (and apologized, of course), dug out an old Windows laptop, proudly created a new user account with my authentic Chinese name for the first time of my li ..read more
Yihui's Blog
1y ago
When I suggested a department chair in 2019 that they may consider opening a blog so that all students and faculty in the department can write together (which sounded exciting to me), he expressed a concern that some readers might remember authors’ mistakes in the posts. Considering the reputation of the whole department, that is a valid concern. However, to err is human (and to forgive is divine). Everyone makes mistakes. I often update my old posts to correct mistakes or write a note saying certain information is oudated after a few years.
My notes did not have a formal form. Sometimes a not ..read more
Yihui's Blog
1y ago
When we say “R Markdown”, we usually refer to the rmarkdown package, which is based on Pandoc and knitr. Prior to the rmarkdown package, there actually existed an older version of R Markdown, which was based on the markdown package instead of Pandoc. Later we called this version “R Markdown v1”.
R Markdown v1 was more or less an experiment, although many people liked it (perhaps because they had suffered for too long from LaTeX). It did not take long before we started developing v2, i.e., rmarkdown. V1 was much less powerful than v2. For example, it only supported HTML output but not LaTeX or ..read more
Yihui's Blog
1y ago
A couple of weeks ago I wrote about a lightweight HTML presentation format, snap slides. Today I want to briefly introduce a simple and lightweight HTML article format. You can find an example page here, which is also its documentation. You can generate an article like this with either the R package markdown or Quarto or any other tool that can generate HTML output. Under the hood, this article format is based on CSS and JS, which can be reused on any web pages.
If you use R Markdown or plain Markdown, you can install.packages('markdown') and specify the output format:
output:
markdown::htm ..read more
Yihui's Blog
1y ago
As I wrote last month, code folding was the most requested feature in blogdown, of which I have given an implementation. Today I will demonstrate an implementation of another top requested feature: tabsets.
How a tabset works
The mechanism of tabsets is fairly simple. It boils down to a click event on a tab link, which triggers the display of a corresponding tab pane. The user interface in HTML is like this:
<div >
<div >Tab 1</div>
<div >Tab 2</div>
<div >Pane 1</div>
<div >Pane 2</div>
</div>
If the first tab link is clic ..read more
Yihui's Blog
1y ago
I just finished reviewing a pull request in the knitr repo that tries to improve the error message when it fails to parse YAML, and I feel three base R functions are worth mentioning to more R users. I have been inspired by Maëlle Salmon’s 3 functions blog series, and finally started writing one by myself.
regexec(): get substrings with patterns
If you want to master string processing using regular expressions (regex) with base R, the two help pages ?grep and ?regexp are pretty much all you need. Although I had read them many times in the past, I did not discover regexec() until about three ye ..read more
Yihui's Blog
1y ago
While I was answering a question from a user last week, I saw a piece of code that, in my opinion, could be shortened. What it does is to set two chunk options, message and warning, to NA or FALSE according the version of the evaluate package.
setHook(packageEvent("knitr", "onLoad"),
function(...) {
message_default <- FALSE
installed <- installed.packages()
if ("evaluate" %in% rownames(installed)) {
evaluate_installed <- installed["evaluate",]
evaluate_version <- evaluate_installed[["Version"]]
evaluate_vers ..read more
Yihui's Blog
1y ago
Personally I do not like the dark mode. I love sharp full-black text on clean white background, which gives me the same feeling as reading on paper. Reading in the dark mode makes me feel lost in the dark, but I know many people are the opposite, therefore in this crowded world of numerous dichotomous choices, web developers and authors have one more decision to make: should the website support the dark mode?
To support the dark mode well from the scratch is not a trivial task. You may have to tweak a lot of colors, depending on how many colors you use on your webiste. That is one of the reaso ..read more