Rapporter / pander

An R Pandoc Writer: Convert arbitrary R objects into markdown
http://rapporter.github.io/pander/
Open Software License 3.0
294 stars 66 forks source link

Add support for plotly objects, and possibly htmlwidget objects? #276

Open happyshows opened 8 years ago

happyshows commented 8 years ago

Error in x[[i]] : subscript out of bounds In addition: Warning message: In pander.default(x$result) : No pander.method for "plotly", reverting to default.No pander.method for "htmlwidget", reverting to default.

daroczig commented 7 years ago

Thanks for this report. Can you please provide some details on the use case? I mean why do you run a plotly object through pander? Or are you using Pandoc.brew?

happyshows commented 7 years ago

Hi,

I was attempting to use pander to dynamically create markdown files that allow me to embed plotly visualization in there, so that reader will have some flexibility in the generated html file to do filtering, regrouping.

daroczig commented 7 years ago

Thanks a lot, makes a lot of sense, will try to get some time to add support for it soon.

timwoelfle commented 3 years ago

Any news or workarounds on this? I love using pander to dynamically create documents with static ggplot figures and it would be awesome to be able to do the same with plotly. I'm using R 4.0.3 and pander 0.6.3 and I still get the same error reported by the host. Here's the code I'm using:

evalsOptions("width", 900)
evalsOptions("height", 600)
myReport <- Pandoc$new(title="Plots")

for (name in names(plots)) {
  myReport$add.paragraph(paste0("## ", name))
  myReport$add(plots[[name]])
}

myReport$add.paragraph("") # hack, otherwise there is a figure in the TOC

myReport
daroczig commented 3 years ago

Sorry for not making this happen sooner. @timwoelfle, can you please edit your above example to make it reproducible? Eg creating the list of plots. Please feel free to keep it to a super simple minimal example.

timwoelfle commented 3 years ago

Attached is a reproducible example! The ggplot objects work, but the plotly objects don't. You have to run the notebook in RStudio (e.g. with "Run all") and save it as a notebook, looking at the auto-generated test.nb.html (also attached, knitting won't work).