ygeunkim / rmdtool

Private tools for writing R markdown documents

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rmdtool

Private tools for writing R markdown documents

Motivated by StackOverflow, including my own answers

profile for Blended at Stack Overflow, Q&A for professional and enthusiast programmers


Install

Denote that this package is made for private usage, so it might not be comfortable to use.

devtools::install_github("ygeunkim/rmdtool")

Print matrix

(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 (1, 2, 3)^T. Writing matrix, however, is quite annoying. If we do the same for the matrix, we will get 1, 2, 3, 4, 5, 6, 7, 8, 9. So we need to add new method for knitr::knit_print().

library(rmdtool)

Now consider

$`r A`$

This inline print method \begin{bmatrix} 1&4&7 \\ 2&5&8 \\ 3&6&9 \\ \end{bmatrix} gives bmatrix form of the matrix. Also,

$$`r A`$$

\begin{bmatrix} 1&4&7 \\ 2&5&8 \\ 3&6&9 \\ \end{bmatrix}

About

Private tools for writing R markdown documents

License:Other


Languages

Language:R 100.0%