plotly R libary contains a function
ggplotly which will convert
ggplot2 figures into graphs drawn with
plotly.js and saved in your online plotly account.
plotly is not (yet) available on CRAN, but you can install it via devtools:
install.packages("viridis") # dependency install.packages("devtools") devtools::install_github("ropensci/plotly")
If you don't already have a plotly account, either signup online or use the
signup() function (see the
help(signup) page for more details).
Note you can check if you have a username and API key with:
Find your credentials in our online settings. Set them in your R session with:
Save these commands in your .Rprofile file to be run everytime you start R.
Your API key for account on the public cloud will be different than the API key in Plotly On-Premise. Visit https://plotly.your-company.com/settings/api/ to find your Plotly On-Premise API key. Remember to replace "your-company.com" with the URL of your Plotly On-Premise server.
If your company has a Plotly On-Premise server, change the R API endpoint so that it points to your company's Plotly server instead of Plotly's cloud.
In your .RProfile write:
Remember to replace "your-company" with the URL of your Plotly On-Premise server.
ggplotfigures into Plotly graphs
library(plotly) set.seed(100) d <- diamonds[sample(nrow(diamonds), 1000), ] p <- ggplot(data = d, aes(x = carat, y = price)) + geom_point(aes(text = paste("Clarity:", clarity)), size = 4) + geom_smooth(aes(colour = cut, fill = cut)) + facet_wrap(~ cut) (gg <- ggplotly(p))