I am using R 3.3.3 and I am working on an R presentation trying to plot a ggplot graph with plotly. My chunk code in the R markdown file is:
```{r plot, echo=FALSE, message=TRUE, warning=TRUE}
G <- ggplot(data=gender_gap, aes(x=value_girls, y=value_boys, color=gender_gap))+ geom_point()+ geom_text(label=gender_gap$LOCATION, hjust=1, vjust=1, size=4)+ geom_abline(intercept = 0, slope = 1)
ggplotly(G)
```
The plot is nicely printed in the viewer, but in the slide I get the following message:
"Error in file(con, "rb") : cannot open the connection"
In advance thank you for your wise advice!
I too was having the same problem but the below code solved mine.
```{r}
library(plotly)
set.seed(100)
d <- diamonds[sample(nrow(diamonds), 1000), ]
p=plot_ly(d, x = ~carat, y = ~price, color = ~carat,
size = ~carat, text = ~paste("Clarity: ", clarity))
htmlwidgets::saveWidget(as.widget(p), file = "demo.html")
```
<iframe src="demo.html" style="position:absolute;height:100%;width:100%"></iframe>
I had the same issue and fixed it by creating the presentation with R Markdown instead of R presentation.
I chose Html ioslides as Output format and it went smoothly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With