英文:
How to solve eval error in RMarkdown referred to dimension
问题
我在RMarkdown中遇到渲染问题。
---
title: "trial"
author: "X"
date: "X"
output:
word_document:
toc: yes
toc_depth: '2'
html_document:
fig_caption: yes
theme: journal
toc: yes
toc_depth: 2
pdf_document:
fig_caption: yes
fig_crop: no
fig_height: 4
fig_width: 7
highlight: haddock
keep_tex: yes
number_sections: yes
toc: yes
toc_depth: 2
header-includes:
- \usepackage{graphicx}
- \usepackage{float}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(fig.path='figure/graphics-',
cache.path='cache/graphics-',
fig.align='center',
external=TRUE,
echo=TRUE,
warning=FALSE,
fig.pos='H', ft.tabcolsep=0, ft.latex.float = "none"
)
dat_na = data.frame(v1 =ifelse(ttINT_1$HMM$tt$incl == "-", NA, ttINT_1$HMM$tt$incl),
v2 = ifelse(ttINT_1$IMM$tt$incl == "-",NA, ttINT_1$IMM$tt$incl),
v3 = ifelse(ttINT_1$LMM$tt$incl == "-",NA, ttINT_1$LMM$tt$incl)
)
它报错了:
我无法理解它指的是什么。将代码作为代码块单独处理可以解决问题。
【注意】我已保留代码块的格式,只提供翻译,不回答问题。
<details>
<summary>英文:</summary>
I am struggling with this rendering oin RMarkdown
---
title: "trial"
author: "X"
date: "X"
output:
word_document:
toc: yes
toc_depth: '2'
html_document:
fig_caption: yes
theme: journal
toc: yes
toc_depth: 2
pdf_document:
fig_caption: yes
fig_crop: no
fig_height: 4
fig_width: 7
highlight: haddock
keep_tex: yes
number_sections: yes
toc: yes
toc_depth: 2
header-includes:
- \usepackage{graphicx}
- \usepackage{float}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(fig.path='figure/graphics-',
cache.path='cache/graphics-',
fig.align='center',
external=TRUE,
echo=TRUE,
warning=FALSE,
fig.pos='H', ft.tabcolsep=0, ft.latex.float = "none"
)
---
`{r echo=TRUE, message=FALSE, warning=FALSE, paged.print=FALSE}
dat_na = data.frame(v1 =ifelse(ttINT_1$HMM$tt$incl == "-", NA, ttINT_1$HMM$tt$incl),
v2 = ifelse(ttINT_1$IMM$tt$incl == "-",NA, ttINT_1$IMM$tt$incl),
v3 = ifelse(ttINT_1$LMM$tt$incl == "-",NA, ttINT_1$LMM$tt$incl)
)
It turns this error:
[![enter image description here][1]][1]
I cannot understand what it refers to. It works isolating the code as a chunk
[1]: https://i.stack.imgur.com/Hs1fD.png
</details>
# 答案1
**得分**: 1
你的YAML应该在 `---` 之间,你的代码块没有正确使用 ` sign 来创建,应该像这样:
```yaml
---
title: "trial"
author: "X"
date: "X"
output:
word_document:
toc: yes
toc_depth: '2'
html_document:
fig_caption: yes
theme: journal
toc: yes
toc_depth: 2
pdf_document:
fig_caption: yes
fig_crop: no
fig_height: 4
fig_width: 7
highlight: haddock
keep_tex: yes
number_sections: yes
toc: yes
toc_depth: 2
header-includes:
- \usepackage{graphicx}
- \usepackage{float}
---
knitr::opts_chunk$set(fig.path='figure/graphics-',
cache.path='cache/graphics-',
fig.align='center',
external=TRUE,
echo=TRUE,
warning=FALSE,
fig.pos='H', ft.tabcolsep=0, ft.latex.float = "none"
)
dat_na = data.frame(v1 =ifelse(ttINT_1$HMM$tt$incl == "-", NA, ttINT_1$HMM$tt$incl),
v2 = ifelse(ttINT_1$IMM$tt$incl == "-",NA, ttINT_1$IMM$tt$incl),
v3 = ifelse(ttINT_1$LMM$tt$incl == "-",NA, ttINT_1$LMM$tt$incl))
英文:
Your yaml should be between ---
and your chunks are not rightly created using the ` sign like this:
---
title: "trial"
author: "X"
date: "X"
output:
word_document:
toc: yes
toc_depth: '2'
html_document:
fig_caption: yes
theme: journal
toc: yes
toc_depth: 2
pdf_document:
fig_caption: yes
fig_crop: no
fig_height: 4
fig_width: 7
highlight: haddock
keep_tex: yes
number_sections: yes
toc: yes
toc_depth: 2
header-includes:
- \usepackage{graphicx}
- \usepackage{float}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(fig.path='figure/graphics-',
cache.path='cache/graphics-',
fig.align='center',
external=TRUE,
echo=TRUE,
warning=FALSE,
fig.pos='H', ft.tabcolsep=0, ft.latex.float = "none"
)
```
```{r echo=TRUE, message=FALSE, warning=FALSE, paged.print=FALSE}
dat_na = data.frame(v1 =ifelse(ttINT_1$HMM$tt$incl == "-", NA, ttINT_1$HMM$tt$incl),
v2 = ifelse(ttINT_1$IMM$tt$incl == "-",NA, ttINT_1$IMM$tt$incl),
v3 = ifelse(ttINT_1$LMM$tt$incl == "-",NA, ttINT_1$LMM$tt$incl))
```
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论