从knitr version 1.16开始,您可以使用选项sql.show_interpolated = TRUE
来 Select 加入此行为.它已经被添加到这个PR中.
请从以下现有问题中查看此示例:
---
title: "Get SQL with evaluated variables from SQL chunks"
output: html_document
---
In order to provide a reproducible example, we use dplyr and dbplyr with `tbl_memdb` to load a table into a memory db.
```{r}
library(dplyr)
library(dbplyr)
iris_db <- tbl_memdb(iris)
# we isolate the connection object
con <- src_memdb()$con
species <- "setosa"
```
We check that it works with SQL chunk to filter data into an R object
```{sql, connection=con, output.var="iris_subset", sql.show_interpolated = TRUE}
SELECT * FROM iris WHERE Species = ?species
```
```{r}
head(iris_subset)
```
You'll see the following where ?species
has been replaced