i unable render rmarkdown documents rscript
if have dplyr
sqlite calls in them. take mwe (test.rmd
) calls table in local copy of dplyr::lahman_sqlite()
table.
--- title: "testfile" output: html_document --- ```{r setup, include=false} library(dplyr) lahman <- src_sqlite("lahman.sqlite") ``` ```{r} tbl(lahman, "batting") ```
in live r console session can call rmarkdown::render("test.rmd")
, , document built expected. if call rscript -e 'rmarkdown::render("test.rmd")'
on command line, following error:
quitting lines 12-13 (test.rmd) error in usemethod("db_query_fields") : no applicable method 'db_query_fields' applied object of class "sqliteconnection" calls: render ... make_tbl -> structure -> op_base_remote -> db_query_fields
i've attached sessioninfo below, i've duplicated error on 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 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
the problem comes fact when using rscript
methods
package not loaded. it's therefore required load explicitly adding library(methods)
in setup chunk instance.
Comments
Post a Comment