我正在处理一个我收到的降价文件,它希望使用我以前从未使用过的 knitr 包将一些脚本编写成代码块。
我遇到的问题是脚本在放置在块中时似乎没有工作,但是当我在该上下文之外运行它们时工作得很好。
例子:
sqlite <- dbDriver("SQLite")
con <- dbConnect(sqlite,"db/sqlite/table.db")
这样可行。
```{r db_connect}
sqlite <- dbDriver("SQLite")
con <- dbConnect(sqlite,"db/sqlite/table.db")
```
这不起作用。这是错误的回溯:
Error in rsqlite_connect(dbname, loadable.extensions, flags, vfs) : Could
not connect to database: unable to open database file
8. stop(structure(list(message = "Could not connect to database:\nunable to open database file", call = rsqlite_connect(dbname, loadable.extensions, flags, vfs), cppstack = structure(list(file = "", line = -1L, stack = "C++ stack not available on this system"), .Names = c("file", ...
7. rsqlite_connect(dbname, loadable.extensions, flags, vfs)
6. initialize(value, ...)
5. initialize(value, ...)
4. new("SQLiteConnection", ptr = rsqlite_connect(dbname,loadable.extensions, flags, vfs), dbname = dbname, flags = flags, vfs = vfs, loadable.extensions = loadable.extensions, ref = new.env(parent = emptyenv()))
3. .local(drv, ...)
2. dbConnect(sqlite, "db/sqlite/table.db")
1. dbConnect(sqlite, "db/sqlite/table.db")
有人对如何解决此问题有任何建议吗?