R notebooks allow us to write SQL code directly with a dedicated chunk defined by {sql}
. However, that call isn't very useful until we get its output and process it in the next R chunk:
```{sql output.var="data"}
SELECT * FROM foo
```
```{r}
dt = data.table(data)
# do stuff with the data
```
Is there a way to bind such chunks together, so that running one automatically runs the other as well? Even better, can it be one-way (such that running the SQL automatically calls the R block, but running the R block doesn't run the SQL)?
To clarify, I'd like to know if it's possible to do something like
```{sql output.var="data" runNextChunk=TRUE}
SELECT * FROM foo
```
Or perhaps
```{sql output.var="data" runAfter="bar"}
SELECT * FROM foo
```
```{r name="bar"}
dt = data.table(data)
# do stuff with the data
```
Obviously, once the notebook is complete, I can knit it and all the cells will be processed. However, while developing I often find myself making adjustments to my SQL call and then having to move the caret to the next chunk and runing it as well.
I've looked at the R Markdown docs, but haven't found anything like this, so here's to hoping I just missed it.