【发布时间】:2018-11-20 05:40:03
【问题描述】:
我试图只显示几个变量值,使用 RMarkdown 中的内联代码。 第一个内联代码正确显示值(数字 3),但第二个显示代码块而不是预期值(datos[2] 而不是数字 9)。 两者都使用相同的sintaxis。 输出到 HTML 时会出现错误输出。输出到 Word 工作正常。知道为什么会发生这种行为,我该如何解决? 我正在使用 R 3.3.3、RStudio 1.1.419、MacOS X Yosemite。 代码如下:
---
title: "Untitled"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
datos <- c(3,9,4,7)
```
The first value in datos is `r datos[1]` and the second is `r datos[2]`.
输出是:
Untitled
The first value in datos is 3 and the second is datos[2].
非常感谢您的帮助
【问题讨论】:
-
到底是什么问题?我刚刚尝试运行您的代码,它工作得很好,产生了所需的输出。 Untitled datos 中的第一个值是 3,第二个是 9。我使用的是 R 4.0.2,Rstudio 1.3.1056
标签: r r-markdown inline-code