我在 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 文件,发现以前保留了换行符。有谁知道为什么这种行为会改变,更重要的是,是否有办法将其改回来?