0

作为标题 - 我希望能够使用 YAML 标签,如 toc: true 和 toc_float: true 在 RNotebook 文件中使用。目前我有这个:

```

标题:“R 笔记本”输出:html_notebook:

目录:真

第 1 节

这是一个R Markdown笔记本。W

第 2 节

{r} plot(cars) ```

这给了我一个错误: yaml::yaml.load(string, ...) 中的错误:扫描仪错误:在第 3 行第 1 列扫描下一个标记时发现无法在第 3 行第 1 列启动任何标记的字符

文档加载,但没有目录。

4

1 回答 1

0

试试这个 rstudio basic 的例子

---
title: "R Notebook"
output:
  html_notebook:
    toc: yes
    toc_float: yes
  html_document:
    toc: yes
---

# blabla section 1

This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code. 

Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Ctrl+Shift+Enter*. 

```{r}
plot(cars)
```

# blabla section 2

Add a new chunk by clicking the *Insert Chunk* button on the toolbar or by pressing *Ctrl+Alt+I*.

When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the *Preview* button or press *Ctrl+Shift+K* to preview the HTML file).
于 2017-08-03T11:02:31.850 回答