R Markdown: How do I show file contents

╄→гoц情女王★ 提交于 2020-07-18 09:39:25

问题


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.


回答1:


You can use either

```{r engine='bash', comment=''}
cat a.csv
```

or

```{r comment=''}
cat(readLines('a.csv'), sep = '\n')
```

The former solution requires Bash. The latter one is pure R.



来源:https://stackoverflow.com/questions/29257985/r-markdown-how-do-i-show-file-contents

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!