Pretty print sql code from separate file with knitr

你离开我真会死。 提交于 2019-12-03 19:13:01

问题


Knitr produces a nice, syntax highlighted code when using a code chunk as below.

```sql
SELECT column
FROM table
```

Is it possible to achieve the same thing but with the sql code stored in a file? Something like:

```sql
read_chunk('mycode.sql')
```

回答1:


I think you can use an inline R expression to achieve it:

```sql
`r xfun::file_string('mycode.sql')`
```


来源:https://stackoverflow.com/questions/24524594/pretty-print-sql-code-from-separate-file-with-knitr

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