- Importance of visualising data
- Interactive graphics in R
googleVis
htmlwidgets
ggvis
- Shiny
- Your turn
Garth Tarr
googleVis
htmlwidgets
ggvis
It may not be long before presentations with static plots are as old fashioned as whipping out your overhead transparencies.
install.packages("googleVis")
require(googleVis)
demo(WorldBank, package = "googleVis")
Markus Gesmann created the googleVis
package which accesses the Google Chart API directly from R
The functions of the package allow users to visualise data with the Google Chart Tools without uploading their data to Google
The output of googleVis functions is html code that contains the data and references to JavaScript functions hosted by Google
Using the Google Visualisation API with R, The R Journal, 3(2):40-44, December 2011 and googleVis package vignette
Function | Description |
---|---|
gvisAnnotatedTimeLine |
Annotated Time Line |
gvisAnnotationChart |
Annotation Chart |
gvisAreaChart |
Area Chart |
gvisBarChart |
Bar Chart |
gvisBubbleChart |
Bubble Chart |
gvisCalendar |
Calendar Chart |
gvisCandlestickChart |
Candlestick chart |
gvisColumnChart |
Column Chart |
gvisComboChart |
Combo Chart |
gvisGauge |
Gauge |
gvisGeoChart |
Geo Chart |
gvisGeoMap |
Geo Map |
gvisHistogram |
Histogram Chart |
gvisIntensityMap |
Intensity Map |
gvisLineChart |
Line Chart |
gvisMap |
Maps |
gvisMotionChart |
Motion Chart |
gvisOrgChart |
Org Chart |
gvisPieChart |
Pie Chart |
gvisSankey |
Sankey Chart |
gvisScatterChart |
Scatter Chart |
gvisSteppedAreaChart |
Stepped Area Chart |
gvisTable |
Table Chart |
gvisTimeline |
Timeline Chart |
gvisTreeMap |
Tree Map |
install.packages("devtools")
devtools::install_github("garthtarr/mplot")
require(mplot)
install.packages("mplot")
vis()
for variable inclusion and model stability plotsaf()
for the adaptive fencebglmnet()
for bootstrapping glmnetmplot()
for an interactive Shiny interfaceTarr G, Mueller S and Welsh AH (2015). “mplot: An R package for graphical model stability and variable selection.” arXiv:1509.07583 [stat.ME].
mplot
packagerequire(mplot)
lm.d = lm(y ~ ., data = diabetes)
vis.d = vis(lm.d, B = 200)
plot(vis.d, which = "vip")
mplot
packageplot(vis.d, which = "boot", highlight = "ltg")
mplot
packageaf.d = af(lm.d, B = 200, n.c = 100, c.max = 100)
plot(af.d)
htmlwidgets
is a package that lets you relatively easily link R with JavaScript.
Some examples:
networkD3
: force directed networks, Sankey diagrams and tree networksedgebundleR
: hierarchical edge bundle plotspairsD3
: interactive scatter plot matricesdygraphs
: charting time-series dataleaflet
: dynamic mapsDT
: interactive HTML data tablesrpivotTable
: build pivot tables to dynamically slice, dice and plot your datainstall.packages("magrittr")
require(magrittr)
awesome_data =
raw_interesting_data %>%
transform(somehow) %>%
filter(the_good_parts) %>%
finalize
require(magrittr)
x = rnorm(10)
x %>% max
## [1] 1.405986
max(x)
## [1] 1.405986
x %>% sort
## [1] -0.97010061 -0.74849748 -0.60678533 -0.38610363 -0.03629047
## [6] 0.01187292 0.42919359 0.65649122 0.78735912 1.40598620
sort(x)
## [1] -0.97010061 -0.74849748 -0.60678533 -0.38610363 -0.03629047
## [6] 0.01187292 0.42919359 0.65649122 0.78735912 1.40598620
x %>% sort %>% round(1)
## [1] -1.0 -0.7 -0.6 -0.4 0.0 0.0 0.4 0.7 0.8 1.4
round(sort(x), 1)
## [1] -1.0 -0.7 -0.6 -0.4 0.0 0.0 0.4 0.7 0.8 1.4
x %>% sort %>% round(1) %>% plot
plot(round(sort(x), 1))
Similar to JavaScript's chaining:
d3.select("body")
.append("p")
.text("New paragraph!");
%<>%
x %<>% sort %>% round(1)
x
## [1] -1.0 -0.7 -0.6 -0.4 0.0 0.0 0.4 0.7 0.8 1.4
ggplot()
to ggvis()
Read more: ggvis.rstudio.com
rCharts
: Interactive JS Charts from Rdevtools::install_github("ramnathv/rCharts")
plotly
: Interactive Graphics via Plotly's JS Graphing Libraryinstall.packages("plotly")
rggobi
: Interface between R and GGobiTo get started look at Wickham, Lawrence, Lang, Swayne (2008). "An Introduction to rggobi", R_News, 8(2) 3-7.
qtlcharts
: Interactive charts for QTL datainstall.packages("qtlcharts")
I wanted a way to interactively explore the results of a mega-simulation study from my PhD thesis.
Try loading it from GitHub :
install.packages("huge")
shiny::runGitHub("robnetwork", "garthtarr")
Otherwise it's also hosted here: Shinyapps.io
There's a button in RStudio that lets you push it to their server.
Host your app on GitHub and then use code like this:
shiny::runGitHub('robnetwork', 'garthtarr')
sessionInfo()
## R version 3.2.2 (2015-08-14)
## Platform: x86_64-apple-darwin13.4.0 (64-bit)
## Running under: OS X 10.10.5 (Yosemite)
##
## locale:
## [1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] d3heatmap_0.6.1 xts_0.9-7 zoo_1.7-12
## [4] huge_1.2.7 lattice_0.20-33 Matrix_1.2-3
## [7] dygraphs_0.5 igraph_1.0.1 MASS_7.3-45
## [10] networkD3_0.2.6 BiocInstaller_1.20.1 qtlcharts_0.5-25
## [13] magrittr_1.5 ggplot2_1.0.1 tidyr_0.3.1
## [16] dplyr_0.4.3 readr_0.2.2 knitcitations_1.0.7
## [19] knitr_1.11 mplot_0.7.7 edgebundleR_0.1.2
## [22] pairsD3_0.1.0 shiny_0.12.2 ggvis_0.4.2.9000
## [25] rCharts_0.4.5
##
## loaded via a namespace (and not attached):
## [1] Rcpp_0.12.2 lubridate_1.5.0 png_0.1-7
## [4] assertthat_0.1 digest_0.6.8 foreach_1.4.3
## [7] mime_0.4 R6_2.1.1 plyr_1.8.3
## [10] evaluate_0.8 httr_1.0.0 lazyeval_0.1.10
## [13] curl_0.9.4 whisker_0.3-2 googleVis_0.5.10
## [16] proto_0.3-10 labeling_0.3 devtools_1.9.1
## [19] RefManageR_0.8.63 stringr_1.0.0 htmlwidgets_0.5
## [22] RCurl_1.95-4.7 munsell_0.4.2 httpuv_1.3.3
## [25] base64enc_0.1-3 htmltools_0.2.6 codetools_0.2-14
## [28] XML_3.98-1.3 bitops_1.0-6 grid_3.2.2
## [31] jsonlite_0.9.19 xtable_1.8-0 gtable_0.1.2
## [34] DBI_0.3.1 formatR_1.2.1 scales_0.3.0
## [37] bibtex_0.4.0 stringi_1.0-1 reshape2_1.4.1
## [40] rjson_0.2.15 RColorBrewer_1.1-2 iterators_1.0.8
## [43] tools_3.2.2 RJSONIO_1.3-0 markdown_0.7.7
## [46] rsconnect_0.4.1.4 parallel_3.2.2 yaml_2.1.13
## [49] slidify_0.5 colorspace_1.2-6 shinydashboard_0.5.1
## [52] poirot_0.0.2 memoise_0.2.1