dplyr
SQLiteコールがある場合、Rscript
でRmarkdownドキュメントをレンダリングできません。このMWE(test.Rmd
)を取って、dplyr::lahman_sqlite()
テーブルのローカルコピー内のテーブルを呼び出します。RMarkdownはsqlite接続でRscriptからレンダリングされません
---
title: "TestFile"
output: html_document
---
```{r setup, include=FALSE}
library(dplyr)
lahman <- src_sqlite("lahman.sqlite")
```
```{r}
tbl(lahman, "Batting")
```
ライブのRコンソールセッションでは、私はrmarkdown::render("test.Rmd")
を呼び出すことができ、このドキュメントは期待どおりに構築されています。しかし、私は、コマンドラインでRscript -e 'rmarkdown::render("test.Rmd")'
を呼び出す場合、私は次のエラーを取得:
Quitting from lines 12-13 (test.Rmd)
Error in UseMethod("db_query_fields") :
no applicable method for 'db_query_fields' applied to an object of class "SQLiteConnection"
Calls: render ... make_tbl -> structure -> op_base_remote -> db_query_fields
を私は以下の私のSessionInfoを添付しましたが、私はこのOS X上のエラーなどのUbuntuを複製しました。
R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin15.5.0 (64-bit)
Running under: OS X 10.11.6 (El Capitan)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_0.5.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.5 digest_0.6.9 assertthat_0.1 R6_2.1.2 DBI_0.4-1 formatR_1.4 magrittr_1.5 evaluate_0.9
[9] RSQLite_1.0.0 stringi_1.1.1 rmarkdown_0.9.6 tools_3.3.1 stringr_1.0.0 Lahman_4.0-1 yaml_2.1.13 htmltools_0.3.5
[17] knitr_1.13 tibble_1.0
'dplyr''ライブラリ()'の後に 'requireNamespace(" RSQLite ")'を追加します。 – hrbrmstr
@hrbrmstrエラーはまだそこにあります。そして、dplyrライブラリーをロードすると、すでにその名前空間がロードされています。 – gregmacfarlane
一方、 'library(RSQLite)'を明示的に呼び出すと、実際には動作します。 Rscriptが名前空間呼び出しをしているのが不思議です... – gregmacfarlane