Ggplot2 Function

Column 1

Example

Column 2

Comment

Plotly is an easy to use function to produce interactive graph. An simple way to demonstrate that is to use it in combination to ggplot2.

Using the diamonds dataset, we plot the price as a function of the diamond size (carat) and we use the color to represent the clarity of the diamonds.

Plot_ly Function

Column 1

Comment

Going further with plotly:

Plotly also proposes a range of function to improve the interactivity with the graph. In the following R code, we will produce a range slider of the Amazon stock.

We will use the quantmod package to get the price of the amazon stocks and plot the time series.

Data Import

# Download Amazon stock price
getSymbols("AMZN")
[1] "AMZN"
# Convert dataset to a dataframe and add Date column
AMZN_plotly <- as.data.frame(AMZN) 
AMZN_plotly$Date <- row.names(AMZN_plotly)

Quantmod Package plot

Column 2

Plot_ly Plot

Conclusion

Column 1

Conclusion

Plotly is a very efficient way to produce interactive visualization of the data.

I enjoyed going through the examples on their website and my eyes was caught with the great possibility of making a full dashboard.

Visit:

https://plot.ly/feed/

Column 2

R session Info

R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 14393)

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] quantmod_0.4-8       TTR_0.23-1           xts_0.9-7           
[4] zoo_1.8-0            plotly_4.6.0         ggplot2_2.2.1.9000  
[7] htmltools_0.3.6      flexdashboard_0.5    RDocumentation_0.8.0

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.10        plyr_1.8.4          tools_3.3.3        
 [4] digest_0.6.12       lattice_0.20-34     viridisLite_0.2.0  
 [7] jsonlite_1.4        evaluate_0.10       memoise_1.1.0      
[10] tibble_1.3.0        gtable_0.2.0        shiny_1.0.3        
[13] DBI_0.6-1           crosstalk_1.0.0     curl_2.6           
[16] yaml_2.1.14         proto_1.0.0         withr_1.0.2        
[19] httr_1.2.1          stringr_1.2.0       dplyr_0.5.0        
[22] knitr_1.15.1        htmlwidgets_0.8     devtools_1.12.0    
[25] rprojroot_1.2       grid_3.3.3          data.table_1.10.4  
[28] R6_2.2.0            githubinstall_0.2.1 rmarkdown_1.5      
[31] tidyr_0.6.1         purrr_0.2.2         magrittr_1.5       
[34] backports_1.0.5     scales_0.4.1        assertthat_0.2.0   
[37] xtable_1.8-2        mime_0.5            colorspace_1.3-2   
[40] httpuv_1.3.3        labeling_0.3        stringi_1.1.5      
[43] lazyeval_0.2.0      munsell_0.4.3       rjson_0.2.15