【发布时间】:2017-04-25 06:32:57
【问题描述】:
我在 Mac 上使用 R v. 3.3.2 和 RStudio v. 1.0.44。我喜欢使用 RMarkdown 和新的 Markdown Notebook 风格。但是,我最近注意到了一种新行为。我的 R 代码块中的换行符不会反映在 HTML 笔记本文件中。例如,我的 .Rmd 文件中的代码块如下所示:
```{r}
# Creating id for each participant
class_survey$id <- rownames(class_survey)
# Reoder the columns in the data frame so that ID comes first
class_survey <- class_survey[c(44, 1:43)]
# Rename the variables
class_survey <- class_survey %>%
rename(children = Q19_1, gender = Q26, color = Q27)
```
在 nb.html 文档中呈现如下:
# Creating id for each participant
class_survey$id <- rownames(class_survey)
# Reoder the columns in the data frame so that ID comes first
class_survey <- class_survey[c(44, 1:43)]
# Rename the variables using dplyr
# new name = old name
class_survey <- class_survey %>%
rename(children = Q19_1, gender = Q26, color = Q27)
我回过头来查看我的一些“旧”nb.html 文件,发现以前保留了换行符。有谁知道为什么这种行为会改变,更重要的是,是否有办法将其改回来?
【问题讨论】:
-
这真的很奇怪。对我来说(MacOS Sierra、R v3.3.1、Rstudio v.1.0.44)呈现为 HTML 会保留换行符....
-
来自 RStudio 的您好!看起来这是我们笔记本渲染器中的一个错误。我们已经与我们的开发团队取得了联系。
-
@Jonathan 感谢您告诉我们!
-
密切相关的问题,显然是最新版本的 RStudio 中的一个错误:github.com/rstudio/rstudio/issues/6399。
标签: r rstudio knitr r-markdown rnotebook