首页 > 解决方案 > 在 r markdown 中为打印命令修剪空白

问题描述

当我使用命令打印数据帧的字符变量时,R Markdown 在行之间显示不需要的空格print(df[[i]])

在此处输入图像描述

我想要的输出将保留换行符,但在行之间没有空格,类似于以下内容。我可以使用 R 中的命令获得它print(df[[i]]),但我无法在 R Markdown 中获得它

[1] "No negative points"                                                                                                                                                                                                                              
[2] "The course was too short, not all interesting parts of the method could be covered."                                                                                                                                                             
[3] "the exercises to do at home were done together during course hours, which took too long in comparison to learning new stuff daily.  furthermore, I would have wished for even more theoretical input instead of the long R exercises (see above)"

更新:问题似乎是在中间乳胶文件中有时降价避免插入 //. 下面是一个由降价产生的乳胶代码的例子

{[}1{]} ``good overview over underlying principles of web scraping''\\
{[}2{]} ``none''\\
{[}3{]} ``very well presented''\\
{[}4{]} ``- clear distinction between `big data' and `medium data' -
insight into what R can do in terms of webscraping'' {[}5{]} ``- a good
insight into what is possible with R w.r.t. webscraping'' 

任何帮助表示赞赏

标签: rr-markdown

解决方案


鉴于这种:

```{r}
df <- data.frame(c("No negative points", "The course was too short, not all interesting parts of the method could be covered.", "the exercises to do at home were done together during course hours, which took too long in comparison to learning new stuff daily.  furthermore, I would have wished for even more theoretical imput instead of the long R exercises (see above)"), stringsAsFactors = FALSE)
```

尝试results在 Markdown 中使用 R 块的参数:

```{r, results = "asis"}
print(df[[1]])
```

对于像这样的输出:

在此处输入图像描述


推荐阅读