Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pretty print sql code from separate file with knitr

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')
```
like image 745
Rickard Avatar asked Jul 02 '14 06:07

Rickard


1 Answers

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

```sql
`r xfun::file_string('mycode.sql')`
```
like image 181
Yihui Xie Avatar answered Oct 29 '22 15:10

Yihui Xie