Install R (about 1 minute): download here
Install RStudio (about 1 minute): download here
Install ggplot (about 1.5 minutes):
- open RStudio
- type into the console in RStudio:
install.packages('tidyverse')
and hit enter - If it asks "Do you want to install from sources the packages which need compilation?" type
no
and hit enter
library(tidyverse)
x <- c(1, 2, 5, 1, 7, 3, 2, 4, 5, 7, 0, 3, 1)
y <- c(0, 4, 7, 4, 8, 2, 6, 3, 5, 4, 2, 7, 1)
df <- tibble(x, y) # ggplot needs data in data frame format
ggplot(df, aes(x, y)) + geom_point() # scatterplot
See here. We will go through this example step by step. It's going to be fun!
This example doesn't exist yet -- Getting the data into the right shape for plotting is a skill on its own, so this could become the content of for a future workshop.
Full cycle:
- Load data
- Reshape data
- Plot data
(Subjective selection)
If I get stuck with a ggplot problem, I often just use google (for example "ggplot change order of colors"). Usually very efficient; leads you often to helpful answers on stackoverflow (example).
introduction to ggplot by the master himself
another comprehensive introduction (1)