我正在使用units包在rmarkdown文档中生成pdf输出。然而,这些单位无法作为行内代码或代码块使用。是否可能在rmarkdown中使用units?
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