首页 > 解决方案 > R-Markdown 不再编织

问题描述

在过去的几年里,我用我在 R 上的笔记创建了一个广泛的降价文件。今天它不再正确编织,也没有一个备份版本正确编织。输出是正确输出和代码列表之间的交叉;有时以## 为前缀。

---
title: 'The R Companion'
fontsize: 11pt
toc: true
toc_depth: 4
geometry: "top = 2cm, bottom = 1.5cm, left = 2cm, right = 1.5cm"
output: pdf_document

---
\pagebreak

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(tidy.opts=list(width.cutoff=60),tidy=TRUE)
knitr::opts_chunk$set(fig.height = 3.5, fig.width = 7)

library(readr)
library(ggplot2)
library(knitr)
library(kableExtra)
library(lubridate)
library(dplyr)
library(tibble)
library(ggthemes)
library(RColorBrewer)
```

###Basic Data Manipulation

####Vector creation 
```{r}
a <- 1:5
b <- 6:10
c <- append(a,b)
print(c)
# Append after c[4].
append(c, 4.5, after=4)
# Append before c[0].
append(c, c(-1, 0), after = 0)
```

输出(下图)只有 15 个 TOC 列表中的两个,标题尚未编织,输出不完整/错误。RStudio 1.2.1335、R 3.6.0.、Rmarkdown 1.12。谢谢。

The R Companion
Contents
Creating and tidying data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 GraphicsI:Plot,axes,titleandlegend. .............................. 20
1
###Basic Data Manipulation ####Vector creation
## [1] 1 2 3 4 5 6 7 8 910
##  [1]  1.0  2.0  3.0  4.0  4.5  5.0  6.0  7.0  8.0  9.0 10.0
##  [1] -1  0  1  2  3  4  5  6  7  8  9 10   

标签: rr-markdown

解决方案


尝试安装 formatR 包。在我安装它之前它对我不起作用。我刚刚运行了您的代码,这是我在 word doc knit 中得到的输出。这是你想要的?

The R Companion

Basic Data Manipulation
Vector creation
a <- 1:5
b <- 6:10
c <- append(a, b)
print(c)
##  [1]  1  2  3  4  5  6  7  8  9 10
# Append after c[4].
append(c, 4.5, after = 4)
##  [1]  1.0  2.0  3.0  4.0  4.5  5.0  6.0  7.0  8.0  9.0 10.0
# Append before c[0].
append(c, c(-1, 0), after = 0)
##  [1] -1  0  1  2  3  4  5  6  7  8  9 10

推荐阅读