Skip to content

Instantly share code, notes, and snippets.

@petbadger
petbadger / Longitudinal data example.R
Created February 2, 2016 18:02 — forked from johncolby/Longitudinal data example.R
An example showing how to plot longitudinal data in R using base graphics and ggplot2
library(plyr)
library(ggplot2)
# Simulate data
numSubs = 40
x = runif(numSubs, 0, 30)
x = c(x, x + abs(rnorm(numSubs, 2)))
y = 2 + x - 0.02*x^2 + rnorm(2*numSubs, 0, 1)