在r markdown中修剪打印命令的空白区域

时间:2018-04-30 22:36:48

标签: r r-markdown

当我使用命令print(df[[i]])

打印数据框的字符变量时,R Markdown显示行间不需要的空格

enter image description here

我想要的输出会保留换行符,但行之间没有白色空格,类似于以下内容。我只能使用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)"

更新:问题似乎是在中间乳胶文件中,有时降价会避免插入//。下面是markdown

产生的乳胶代码示例
{[}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'' 

感谢任何帮助

1 个答案:

答案 0 :(得分:0)

鉴于此:

```{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)
```

尝试在markdown中使用results参数作为R chunk:

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

输出如:

enter image description here