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)

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)
(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$$



ygeunkim/rmdtool documentation built on July 1, 2019, 1:57 p.m.