trafficonese / widgetframe

Embed htmlwidgets in Responsive iframe.
https://bhaskarvk.github.io/widgetframe/
Other
69 stars 11 forks source link

frameWidget() returns <PATH> not found in RMarkdown documents #9

Closed charliejhadley closed 7 years ago

charliejhadley commented 7 years ago

frameWidget() no longer successfully frames htmlwigets anymore on my machine, attempted with both dev and CRAN builds of widgetframe.

sessionInfo()

R version 3.4.1 (2017-06-30) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS Sierra 10.12.6

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale: [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

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

other attached packages: [1] dygraphs_1.1.1.4 widgetframe_0.3.0 htmlwidgets_0.9 leaflet_1.1.0

loaded via a namespace (and not attached): [1] Rcpp_0.12.12 knitr_1.17 magrittr_1.5 xtable_1.8-2 lattice_0.20-35 R6_2.2.2 stringr_1.2.0
[8] tools_3.4.1 grid_3.4.1 htmltools_0.3.6 crosstalk_1.0.0 yaml_2.1.14 digest_0.6.12 rprojroot_1.2
[15] shiny_1.0.5 rsconnect_0.8.5 evaluate_0.10.1 mime_0.5 rmarkdown_1.6 stringi_1.1.5 compiler_3.4.1 [22] backports_1.1.0 httpuv_1.3.5 zoo_1.8-0

What dev packages do I have?

pkgs <- as.tibble(installed.packages()[,c(1,3:4)])
pkgs %>%
  filter(grepl("9000", Version))
\## A tibble: 1 x 3
\#  Package    Version Priority
\#    <chr>      <chr>    <chr>
\#1    pool 0.1.0.9000     <NA>

RStudio Version

rstudioapi::versionInfo()$version
\# [1] ‘1.0.153’

Sample RMarkdown Document

--- title: "html-document" output: html_document ---

```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ```

## R Markdown

```{r 01} library(leaflet) library(widgetframe) l <- leaflet(height=300) %>% addTiles() %>% setView(0,0,1) frameWidget(l) ### failure: /rmd_output/1/html-document_files/figure-html//widgets/widget_01.html?initialWidth=910&childId=htmlwidget-56f76eccd2ad2dfccf35&parentTitle=html-document&parentUrl=http%3A%2F%2F127.0.0.1%3A37852%2Frmd_output%2F1%2F not found ```

```{r 02} library(dygraphs) ts <- dygraph(nhtemp, main = "New Haven Temperatures", height=250, width='95%') frameWidget(ts) ### failure: /rmd_output/1/html-document_files/figure-html//widgets/widget_02.html?initialWidth=910&childId=htmlwidget-dd050e09c463fe9a0b7b&parentTitle=html-document&parentUrl=http%3A%2F%2F127.0.0.1%3A37852%2Frmd_output%2F1%2F not found ```

Additional Configuration

Pym.js installed via Bower $ bower install pym.js

bhaskarvk commented 7 years ago

I'll investigate, did it break after upgrading from 0.2 ?

charliejhadley commented 7 years ago

Sorry for slow reply, I've been in lovely mountainous(ish) Wales.

Downgraded to 0.2.0 using devtools and have the same issue. widgetframe was previously working for me on this machine, I can try downgrading my entire R installation later this week to help diagnose if needed.

bhaskarvk commented 7 years ago

I think this is something defi. messed up in your R install. I am not able to replicate this at my end.

charliejhadley commented 7 years ago

Okay, I've completely removed and reinstalled R and RStudio from my machine and still have the same issue.

I vote for closing this issue (so I have) and if I ever figure out what went wrong I'll post an update here in case it helps others.

bhaskarvk commented 7 years ago

Do you have any other m/c you can try this on ? Also in an R session, what happens when you do widgetframe::frameWidget(leaflet::leaflet()) ?

Let's keep this open till we figure out what exactly broke.

charliejhadley commented 7 years ago

I'll check on my partner's machine when they're next about.

On my machine your example code successfully displays a leaflet object in the Viewer: r widgetframe::frameWidget(leaflet::leaflet())

It's only in knitted output that I get errors like this: /rmd_output/0/widgetframe_files/figure-html//widgets/widget_01.html?initialWidth=910&childId=htmlwidget-8727e046b480be0bf5d4&parentTitle=html-document&parentUrl=http%3A%2F%2F127.0.0.1%3A21438%2Frmd_output%2F0%2F not found

bhaskarvk commented 7 years ago

Could you upload a minimal reproducible Rmd on gist and link here? Also is the error displayed while the document is knitted or when you try to display the knitted HTML ?

charliejhadley commented 7 years ago

Here's a gist with the .Rmd and .html as my machine generates it https://gist.github.com/martinjhnhadley/20cf9a102fcf870a558f64c05a02505d

RStudio's RMarkdown pane doesn't report any errors, but the " not found" error shows in the resultant html file.

bhaskarvk commented 7 years ago

Looking at your Rmd file https://gist.githubusercontent.com/martinjhnhadley/20cf9a102fcf870a558f64c05a02505d/raw/df824cad077f1cad3d742e894361c166a7fe9429/widgetframe-not-found.Rmd

Why does it have this in the Rmd ?

### failure: /rmd_output/1/html-document_files/figure-html//widgets/widget_01.html?initialWidth=910&childId=htmlwidget-56f76eccd2ad2dfccf35&parentTitle=html-document&parentUrl=http%3A%2F%2F127.0.0.1%3A37852%2Frmd_output%2F1%2F not found
charliejhadley commented 7 years ago

Oversight on my part, removed now.

bhaskarvk commented 7 years ago

I am not able to reproduce this. Could you render it and zip up the whole thing and upload it on box/dropbox? I need to look at the generated files.

charliejhadley commented 7 years ago

Ohh, github supports dragging files into comments - here you go: widgetframe-bug.zip

bhaskarvk commented 7 years ago

OK I just confirmed that this is indeed a bug caused by the recent fix for blogdown. It works correctly if you're storing the dependencies externally like in this example https://raw.githubusercontent.com/bhaskarvk/widgetframe/master/inst/examples/rmarkdown/knitr_example.Rmd

but I'll fix it to make sure that it works even with inlined dependencies it works. In the mean time please use self_contained:FALSE like in my example.

Thanks for reporting!

bhaskarvk commented 7 years ago

Another option is to explicitly set

knitr::opts_chunk$set(widgetframe_widgetsdir = 'widgets')

In the chunk options, with that your wigdets will be stored in a widgets directory, and you don't really need to specify self_contained:FALSE.

jl5000 commented 5 years ago

I think I'm having this same problem...do you know if a fix is likely to be made for being self-contained? I'm making a training document and it would be nice to show off some htmlwidgets.

zlkrvsm commented 4 years ago

Yup, can confirm I have a similar problem to @jl5000.

Although in my case I was fiddling with directories, which is probably a mistake on my part. It's better to keep everything in the same directory.

It's interesting to note something broken in this example, although I can't be sure it's the same issue.

I've managed to workaround the issue with the information present here. Maybe something to include in the vignette?