Last active
July 18, 2016 03:10
-
-
Save jeffreyiacono/d51e0f94a53fe34124958c7d49b5d74d to your computer and use it in GitHub Desktop.
Color-coded Start / End Plotting with R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(reshape2) | |
df <- data.frame(grp = 1:25, start = rnorm(25, 10, 5), end = rnorm(25, 5, 3)) | |
df$end_higher <- df$start < df$end | |
mdf <- melt(df, id.vars = c("grp", "end_higher")) | |
names(mdf) <- c("grp", "end_higher", "category", "value") | |
mdf$grp <- factor(mdf$grp) | |
mdf$category <- factor(mdf$category) | |
mdf$end_higher <- factor(mdf$end_higher) | |
ggplot(mdf, aes(x = category, y = value, group = grp, color = end_higher)) + geom_point() + geom_line() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment