[英]How do I add a space between each comment in Rmarkdown when the output is text from a code chunk?
I have some data which includes comments in an excel file.我有一些数据,其中包括 excel 文件中的注释。 After importing into R, I would like to add the comments at the bottom of some analysis in
RMarkdown
.导入 R 后,我想在
RMarkdown
的一些分析的底部添加注释。 I passed the column to a code chunk and it knits the output.我将该列传递给一个代码块,它编织了 output。 Here is a screenshot -
这是一个屏幕截图 -
As you can see, it's a bit chunked up.如您所见,它有点块状。 Is there a way for me to
有没有办法让我
I know how to add spacing when type n the text, however since this is the output of a code chunk, I have no idea how to add the spacing.我知道在输入文本时如何添加间距,但是由于这是代码块的 output,我不知道如何添加间距。 I have looked online, however, all solutions show how to add spacing when you type in the text as opposed to text from a code chunk.
但是,我在网上查看过,所有解决方案都显示了如何在输入文本时添加间距,而不是代码块中的文本。
Assuming you don't have any special functions or settings affecting the output from your chunk, generating a list from your text can be achieved in the following way假设您没有任何特殊功能或设置影响您的块中的 output,则可以通过以下方式从您的文本生成列表
---
output: pdf_document
---
```{r, results='asis', echo=FALSE}
textTest <- c("I have never seen our strategic plan, if we have one",
"Yes, to corporate partners and high net worth, I have not
heard about an effort to build relationships with leaders of
color, labor leaders, faith leaders, etc.")
cat(paste0("- ", textTest, "\n"))
```
results='asis'
is needed to get the correct text output from the chunk.需要
results='asis'
从块中获取正确的文本 output。 As for the line cat(paste0("- ", textTest, "\n"))
:至于线
cat(paste0("- ", textTest, "\n"))
:
"- "
generates the list structure. "- "
生成列表结构。 The lagging space is necessary if using paste0()
.paste0()
,则需要滞后空间。 Can be omitted if using paste()
.paste()
可以省略。"\n"
generates new lines. "\n"
生成新行。 Use double ( "\n\n"
) to get more space between list entries."\n\n"
) 在列表条目之间获得更多空间。 Consequently, the output in R will look like this因此,R 中的 output 将如下所示
- I have never seen our strategic plan, if we have one
- Yes, to corporate partners and high net worth, I have not
heard about an effort to build relationships with leaders of
color, labor leaders, faith leaders, etc.
Which will be knitted into这将被编织成
for pdf, word and html对于 pdf、字和 html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.