Questo articolo può essere letto anche in italiano

Dear R-enthusiastic,
I discovered Plotly some days ago, and I was fascinated by it.

What is Plotly?
Plotly is a service for creating and sharing data visualizations that also offers statistical analysis tools plus a robust API, the ability to graph custom functions and a built-in Python shell. Among its APIs, there is the R one: Plotly interactive visualization can be created directly from R.

Why should I use Plotly?
With Plotly, R users can easily create a plot within R with a few lines of code and refine it with the online tool. Indeed, it took me a bit of clicking around to figure out how to do things like add a new visualization to existing data or group data by a specific factor, but many tasks were quite doable without having to read instructions or watch tutorial videos. In general, though, it did not take too much work to figure out a good portion of Plotly's capabilities.

Why should I not use Plotly?
Some tasks are less intuitive, such as embedding a visualization into an external Web site, and also some workaround I found on the net doesn't work for me. By the way, interactive plots can be embedded, like in this Washington Post article.
Another drawback of Plotly concerns privacy: it is not clear if I can produce a plot, embed it on my website but not show it to the world through the Plotly website. This will be fixed soon - do not forget this is a beta version - and Plotly will assume a Github like freemium model.

My first plot
The marketing department of a company wants to know how many records of its data base refer to customers and how many to prospect customers. Customers are split into (current) customers and dormant (former) customer.

First of all, I need to install the plotly package and its dependencies.

At this point, I should sign up to Plotly and get an API key. Then, I connect to Plotly from R.

where usr and api are strings containing my username and API key, respectively.

Now I have to build some lists with data to be plotted and plot layout

At this point, I pass all these information to Plotly.

Within my R, I can open my favorite browser to see the results.

Blog readers can view the results below, as exported to PNG, or the interactive version in the Plotly website.

View the interactive version in the Plotly website

How much time consuming is Plotly?
I needed about half an hour to learn how Plotly works and get the API, another half an hour to produce the plot and more than an hour to learn how embed and/or share the plot.

Finally, I am sure I will spend some words about Plotly on the "Programming with R" course that Quantide has organized in Milan, on January 30-31. For more information about this course, please visit the Quantide website.

Print Friendly, PDF & Email

Related Post