Private tools for writing R markdown documents
Motivated by StackOverflow, including my own answers
- numbering figures: figure captions, references using knitr and markdown to html
- display matrices: For R Markdown, How do I display a matrix from R variable
- enables equation reference: Rendering problem cross-reference equation in r markdown HTML
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)
#> [1] 1 2 3
(A <- matrix(1:9, nrow = 3))
#> [,1] [,2] [,3]
#> [1,] 1 4 7
#> [2,] 2 5 8
#> [3,] 3 6 9
In case of vector, we can use the R
object in the latex block. In
fact, we can express this as vector form.
$(`r a`)^T$
Then we can get
. Writing matrix, however, is quite annoying. If we do the
same for the matrix, we will get
. So we need to add new method for
knitr::knit_print()
.
library(rmdtool)
Now consider
$`r A`$
This inline print method
gives
bmatrix
form of the matrix. Also,
$$`r A`$$