2

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

4

1 回答 1

3

如果有人遇到这个问题(我在发布半年后仍然存在),您可以编织到 HTML 文档,代码中的换行符会神奇地出现。不确定为什么在 Rstudio 中使用“预览笔记本”功能按钮时所有链接中断都消失了(即使您在新标签页中打开)。

rstudio 预览下拉菜单

于 2017-04-28T17:27:16.797 回答