我可能对 Markdown 功能越来越贪婪,但是:有没有办法将内联代码添加到 asis 块中?
```{r}
x <- 5
```
```{asis}
The square is `r x^2` # should show up as 'The square is 25'
```
这是一个可能的解决方案:
---
title: "Inline code inside asis"
date: "`r Sys.Date()`"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
x <- 5
```
```{r, results='asis', echo=FALSE}
cat(paste0("The square is ", x^2, ".")) # should show up as 'The square is 25'
```
这解决了您的问题吗?
中提琴