ABSTRACT

This chapter shows some tricks that can be useful for writing and compiling reports more easily and quickly, and also solutions to frequently asked questions. It also shows some solutions to tweaking the typesetting of a report. The default style of knitr is based on the framed package, and that is why we see shaded boxes underneath all code chunks. The inline hook function is used to write inline results into the output. By default, it writes characters as is, and sometimes we may want to escape special characters in or HTML. A solution is to mutate certain characters in the inline expression. The function inline_expr() in knitr provides one solution to the problem. It takes a character string, and wraps it using the appropriate syntax of inline expressions. There is a function rocco() in knitr that provids a two-column layout for HTML documents.