Last active
May 3, 2017 20:13
-
-
Save mkcor/1ca67262c74c590bd6e9 to your computer and use it in GitHub Desktop.
Get started with plotly and knitr!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "knitr_session" | |
author: "Marianne Corvellec" | |
date: '2014-11-14' | |
output: html_document | |
--- | |
(View source here: https://gist.github.com/mkcor/1ca67262c74c590bd6e9) | |
This is an R Markdown document. Markdown is a simple formatting syntax for | |
authoring documents. For more details on using R Markdown see | |
<http://rmarkdown.rstudio.com>. | |
You can embed an R code chunk like this: | |
```{r} | |
summary(cars) | |
``` | |
You can also embed plots, for example: | |
```{r} | |
library(plotly) | |
gg <- ggplot(cars) + geom_point(aes(speed, dist)) | |
gg | |
``` | |
```{r, plotly=TRUE} | |
py <- plotly() | |
py$ggplotly(gg, session="knitr", kwargs=list(filename="cars_knitr", | |
fileopt="overwrite")) | |
``` | |
You can embed a static plot using Markdown syntax: | |
 | |
Notice that we simply appended a supported extension (.png) to the URL where the | |
plotly plot lives. | |
You can also use HTML syntax to embed iframes: | |
<iframe scrolling='no' seamless='seamless' style='border:none' | |
src='https://plot.ly/~MattSundquist/2509' width='800' height='500'></iframe> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually
plotly=T
and the other arguments toggplotly
are also now unnecessary. The following works as a replacement for lines 29-33: