knitr::opts_chunk$set( comment = "#>", collapse = TRUE, out.width = "70%", fig.align = "center", fig.width = 6, fig.asp = .618 ) options(digits = 3) pander::panderOptions("round", 3)
Private tools for writing R markdown documents
Motivated by StackOverflow, including my own answers
Denote that this package is made for private usage, so it might not be comfortable to use.
devtools::install_github("ygeunkim/rmdtool")
(a <- 1:3) (A <- matrix(1:9, nrow = 3))
In case of vector, we can use the R object in the latex block. In fact, we can express this as vector form.
writeLines("$(`r a`)^T$")
Then we can get $(r a)^T$. Writing matrix, however, is quite annoying. If we do the same for the matrix, we will get $r A$. So we need to add new method for knitr::knit_print().
library(rmdtool)
Now consider
writeLines("$`r A`$")
This inline print method $r A$ gives bmatrix form of the matrix. Also,
writeLines("$$`r A`$$")
$$r A$$
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.