Plotting in R

Plotting for R is a major selling point o fthe whole platform. And thanks to projects like shiny it is not only for your own computer but can even be used to backend webapps.

ggplot2

More tidyverse! Probably the favourite plotting system for R these days.

Kieran Healy advises the following set up for visualisation in the tidyverse style :

my_packages <- c("tidyverse", "broom", "coefplot", "cowplot",
    "gapminder", "GGally", "ggrepel", "ggridges",X "gridExtra",
    "interplot", "margins", "maps", "mapproj", "mapdata",
    "MASS", "quantreg", "scales", "survey", "srvyr",
    "viridis", "viridisLite", "devtools")

install.packages(my_packages,
    repos = "http://cran.rstudio.com")

Other plotting systems

R Graphical Manual visualization of all CRAN R package example plots, and is searchable by topic.

Other image wrangling

meme produces image macros from inside R. hexSticker does hexStickers.

MacOS cairo error

Do you get an error like this when plotting SVGs?

unable to load shared object '/usr/local/Cellar/r/3.5.0_1/lib/R/library/grDevices/libs//cairo.so':
dlopen(/usr/local/Cellar/r/3.5.0_1/lib/R/library/grDevices/libs//cairo.so, 6): image not found

That is because homebrew R doesn’t support the cairo library. Yihui recommends:

brew cask install r

or you can install svglite

install.packages("svglite")

and use the device option dev = "svglite". Mind you, svglite can have its own problems. I needed to do the following, on one Kubuntu workstation,

install.packages("devtools")
devtools::install_github('davidgohel/gdtools')
devtools::install_github("r-lib/svglite")