knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

rvisutils

This package is currently still in its very early stages. It will become a collection of visualization functions that I've found useful over the years.

To install, you will need to have the devtools package on your system (if you don't have it, install that with install.packages("devtools")) and then run

devtools::install_github("smach/rvisutils")

To get a full listing of available functions and links to their help files, run

help(package="rvisutils")

Other favorite R data visualizations not packaged as functions here, because the existing functions are more than enough:

HTML time-series graphing -- The dygraphs package is very easy to use. For converting data frames to xts objects, my rvisutils package's df_to_xts() function may be useful.

HTML grouped bar chart -- Check out the rcdimple package. Here is sample code from @timelyportolio:

mydata %>%
+   dimple(
+     x = c("xAxisCategory","BarColor"), y = "value",
+     groups = "CarColor", type = "bar", width = 590, height = 400
+   ) %>%
+   add_legend( x = 60, y = 10, width = 520, height = 20,
+     horizontalAlign = "left"
+   ) %>%
+   default_colors( rainbow(4) )

These can be saved to static images.

Complex static charts -- ggplot2. This package includes 2 thin wrappers for creating barcharts: basic_barchart() grouped_barchart().

There are many other things to be done with ggplot. See examples in the ggplot2 documentation. Also check out the R Graphics Cookbook and the R Graph Catalog. For info on tweaking graphs beyond the type, check this cheat sheet.

Publish interactive versions of ggplot2 visualization on the Web -- plotly.

Interactive HTML maps with points -- Leaflet for R. There's more info on this in my tutorial on useful new R packages.

Interactive HTML choropleth maps -- Leaflet for R. Also check out out Kyle Walker's tutorial, which includes reading in shape files and adding pop-ups.

Static choropleth map of US states/counties or world where proper projection is important -- maps package with ggplot2 qplot. Example of US counties:

library(maps)
library(ggplot2)
counties <- map_data("county")
qplot(long, lat, data = counties, geom="polygon",
      group = group, fill = group) +
  coord_map() # keeps proper aspect ratio

Exploratory static choropleth maps if projection isn't important -- choroplethr

Waffle (square pie) charts -- waffle package

Calendar heat map -- googleVis. Sample code:

dataviz <- gvisCalendar(mydata, datevar="mydate", numvar="myvalue",
                  options=list(title="myheadline",
                               width = 1000, height = 8000))

HTML point graphs, grouped -- rcdimple. Sample code:

dimple(
   ycolname~xcolname,
   groups = c("Group1","Group2"),
   data = mydata,
   type = "bubble"
   ) %>%
  xAxis( type = "addMeasureAxis" ) %>%
  yAxis( type = "addMeasureAxis" ) %>%
  add_legend()


smach/rvisutils documentation built on May 26, 2017, 12:24 p.m.