【发布时间】:2018-10-22 07:25:23
【问题描述】:
我正在使用 rmarkdown 文档中的 units 包进行 pdf 输出。 但是,这些单元既不能用于内嵌代码,也不能用作代码块。是否可以使用带有 rmarkdown 的单位?
RStudio 中用于 rmarkdown 文档的 MWE:
---
title: "Units in R Markdown"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(units)
```
```{r define units, include=FALSE}
len <- set_units(5, mm)
wid <- set_units(10, mm)
```
In-line code: The area of the rectangle is `r len * wid`.
```{r echo = FALSE}
paste("The area of the rectangle is ", len * wid)
```
I'm expecting to see: The area of the rectangle is `r len * wid`mm^2
【问题讨论】:
标签: r pdf r-markdown units-of-measurement