简体   繁体   English

R 不会编织到 html 或 pdf 与 Z9778840A0100CB30C98Z2876A4 块。 eval 中的错误(x,envir = envir):未找到 object '连接'

[英]R wont knit to html or pdf with SQL chunks. Error in eval(x, envir = envir) : object 'connection' not found

connection <- dbConnect(RSQLite::SQLite(), "AmericasCup.sqlite")
dbWriteTable(connection, "results", results, overwrite=TRUE)

```{sql connection=connection, output.var = "outQ6"}
SELECT Code, 
       SUM(Result = 'Win' ) AS Wins,
       SUM(Result = 'Loss') AS Losses
FROM results
GROUP BY Code

Everything runs fine but when I try knit to html or pdf I get the following error:一切运行正常,但是当我尝试编织到 html 或 pdf 时,我收到以下错误: Line 79 is: SELECT Code,第79行是:SELECT代码,

Can anyone tell me what the problem is here, I have tried to research this but cant find anything similar, though I suspect it has something to do with my '''{sql connection=connection, output.var - "outQ6"} setup.谁能告诉我这里的问题是什么,我试图研究这个但找不到类似的东西,虽然我怀疑它与我的 '''{sql connection=connection, output.var - “outQ6”} 设置有关.

Thank you in advance.先感谢您。

I have fixed it, I put this in my r setup instead and now just do {sql} to start sql chunk.我已经修复它,我把它放在我的 r 设置中,现在只需执行 {sql} 即可启动 sql 块。

library(RSQLite)
library(DBI)
connection <- dbConnect(RSQLite::SQLite(), "AmericasCup.sqlite")
knitr::opts_chunk$set(connection = "connection")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM