r - RMarkdown - 第二个内联代码显示代码块而不是值
问题描述
我正在尝试使用 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].
非常感谢您的帮助
解决方案
在第二个块中添加一个r
字母。
The first value in datos is `r datos[1]` and the second is `r datos[2]`.
r
这里用作告诉 R 运行此代码的语句,
datos[2]
并在此处返回号码。
推荐阅读
- c++ - 通过 System() 打开时出现边缘第一个选项卡错误
- python - Seaborn:为双变量 histplot 设置 binrange
- flutter - type '(dynamic) => Null' 不是 '(String, dynamic) => void' of 'f' 的子类型
- java - Spring Boot 应用程序的 Azure 应用程序服务部署在 Jenkins 中不起作用
- angular-cli - 在 Angular 5 中按环境切换开发模式和产品模式
- linux - Linux通过名称掩码将文件从目录移动到目录
- apache-kafka - Kafka JDBC 源连接器插入或更新
- python - 是否可以遍历 prefect.Parameter?
- java - JAVA:从 Heapdump 读取 HashMap 对象内容
- r - 您如何计算在另一列中超过和低于特定数字的幅度(百分比)?