Skip to content

Instantly share code, notes, and snippets.

@leondutoit
Last active January 15, 2016 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leondutoit/52240ead33aaaf064783 to your computer and use it in GitHub Desktop.
Save leondutoit/52240ead33aaaf064783 to your computer and use it in GitHub Desktop.
multiple timeseries ggplot
# install dependencies
options(repos = 'https://cran.rstudio.com/')
install.packages('ggplot2')
# read example data
data <- read.csv('tsdata.csv', colClasses = c('Date', 'numeric', 'character'), stringsAsFactors = FALSE)
# load library and make a timeseries plot
library(ggplot2)
ggplot(data, aes(date, val, colour=label)) + geom_line()
# for more plot customisation see: http://docs.ggplot2.org/current/
date val label
2016-01-01 44 a
2016-01-01 66 b
2016-01-02 23 a
2016-01-02 21 b
2016-01-03 32 a
2016-01-03 29 b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment