1

I have found that when I use includeHTML to include an HTML document that was generated from an Rmarkdown file, and use DT::dataTableOutput/renderDataTable in the same R Shiny app that I get a JavaScript error "Uncaught TypeError: Cannot read property 'filter' of undefined" from within the Shiny JS code. I have found this error occurs in Shiny versions 0.13.0 and 0.14.1.

R-3.1.2> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
[1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
[5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
[9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] DT_0.2       shiny_0.13.0

loaded via a namespace (and not attached):
[1] digest_0.6.8    htmltools_0.3.5 htmlwidgets_0.7 httpuv_1.3.3    magrittr_1.5    mime_0.3        R6_2.1.0        Rcpp_0.12.3    
[9] tools_3.1.2     xtable_1.7-4    yaml_2.1.13`  

I have created an R Shiny app that demonstrates this in GitHub at https://github.com/CliffordWollam/shiny_rmd_error.

jack
  • 2,894
  • 1
  • 13
  • 23
cwall
  • 11
  • 1
  • It's probably a collision of one of the javascript libraries (loaded twice by Shiny itself and by the HTML page). – Xiongbing Jin Oct 22 '16 at 01:09
  • perhaps http://stackoverflow.com/questions/39024390/r-shiny-includehtml-missing-htmlwidgets-in-a-reactive-context and https://github.com/MangoTheCat/radarchart/issues/31 will be helpful. – timelyportfolio Oct 22 '16 at 12:30
  • 1
    @timelyportfolio thanks for the links. I tried setting theme: null and mathjax: null in the Rmd of my example app as suggested in the stackoverflow link and that does indeed solve the problem. Unfortunately you cannot do that and have a floating toc, which I very much want to have in my actual app. – cwall Oct 24 '16 at 15:52
  • I understand. This is still possible but becomes trickier. To get to work, you will need to attach the necessary dependencies `rmarkdown::html_dependency_tocify` and `rmarkdown:::html_dependency_navigation(FALSE, FALSE)` in the `shinyUI` and produce your `HTML` for `includeHTML` with dependencies stripped. – timelyportfolio Oct 24 '16 at 21:46

0 Answers0