tidyverse / reprex

Render bits of R code for sharing, e.g., on GitHub or StackOverflow.

Home Page:https://reprex.tidyverse.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reprex() says the code selected crashes R but it does not

sanjmeh opened this issue · comments

The following code when sent to reprex confuses reprex()

# reprex for stackoverflow
library(plotly)
library(tidyverse)
data.frame(ts = seq(Sys.time(),by = "1 min",length.out = 5),rv = 1:5,kmpl = as.numeric(factor(rpois(5,2)))) %>% 
  plot_ly(x = ~ts,y = ~rv) %>% add_trace(type = "scatter",mode = "markers",color = ~kmpl)

I get the following message from reprex:
This reprex appears to crash R.
See standard output and standard error for more details.

Standard output and error

Error : Functions that produce HTML output found in document targeting gfm-yaml_metadata_block output.
Please change the output type of this document to HTML. Alternatively, you can allow
HTML output in non-HTML formats by adding this option to the YAML front-matter of
your rmarkdown file:

  always_allow_html: true

Note however that the HTML output will not be visible in non-HTML formats.

Well I understand the plotly is producing some sort of html output that is causing this problem but I have no idea where to insert the yaml always_allow_html: true

reprex is never going to work with plotly, because it inherently targets HTML output.

Similar issues for further reading:

#78
#185
#317
#371