R Markdown:如何显示文件内容 [英] R Markdown: How do I show file contents
本文介绍了R Markdown:如何显示文件内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在R markdown(rmd)内转储文本文件的内容.我尝试使用R命令:system("cat a.csv").此命令显示R中的文件内容,但在R studio中编织文件时不产生任何输出.
I want to dump the contents of a text file inside my R markdown (rmd). I tried using the R command: system("cat a.csv"). This command show the file contents in R, but produces no output when I knit the file in R studio.
推荐答案
您可以使用任何一个
```{r engine='bash', comment=''}
cat a.csv
```
或
```{r comment=''}
cat(readLines('a.csv'), sep = '\n')
```
以前的解决方案需要Bash.后一个是纯R.
The former solution requires Bash. The latter one is pure R.
这篇关于R Markdown:如何显示文件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文