Last active
March 8, 2016 02:26
-
-
Save bhive01/173f2c7011f82e94bc49 to your computer and use it in GitHub Desktop.
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
require(ggplot2) | |
require(dplyr) | |
require(plotly) | |
test <- data.frame(year = rep(2001:2016, each=10), group= rep(LETTERS[1:16], times = 10), count = runif(160)) | |
gg <- ggplot(test, aes(x=year, y = count, group = group, colour = group)) + | |
geom_point() + | |
geom_line() | |
gg | |
ggplotly(gg) | |
#gg works | |
## Real data that doesn't | |
test2 <- structure(list(year = c("1999", "2000", "2000", "2001", "2002", | |
"2002", "2003", "2003", "2003", "2003", "2003", "2004", "2004", | |
"2004", "2004", "2004", "2005", "2005", "2005", "2005", "2005", | |
"2005", "2006", "2006", "2006", "2006", "2006", "2006", "2007", | |
"2007", "2007", "2007", "2007", "2007", "2007", "2007", "2008", | |
"2008", "2008", "2008", "2008", "2008", "2008", "2008", "2008", | |
"2009", "2009", "2009", "2009", "2009", "2009", "2009", "2009", | |
"2009", "2009", "2009", "2009", "2010", "2010", "2010", "2010", | |
"2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", | |
"2010", "2011", "2011", "2011", "2011", "2011", "2011", "2011", | |
"2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", | |
"2011", "2011", "2011", "2011", "2012", "2012", "2012", "2012", | |
"2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", | |
"2012", "2012", "2012", "2012", "2012", "2012", "2013", "2013", | |
"2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", | |
"2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", | |
"2013", "2013", "2013", "2013", "2013", "2013", "2013", "2014", | |
"2014", "2014", "2014", "2014", "2014", "2014", "2014", "2014", | |
"2014", "2014", "2014", "2014", "2014", "2014", "2014", "2014", | |
"2014", "2014", "2014", "2014", "2014", "2014", "2014", "2014", | |
"2014", "2014", "2015", "2015", "2015", "2015", "2015", "2015", | |
"2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", | |
"2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", | |
"2015", "2015", "2015", "2015", "2016", "2016", "2016", "2016", | |
"2016", "2016", "2016", "2016", "2016", "2016", "2016"), group = c("WMT", | |
"WDL", "WMT", "WMT", "WMT", "WRS", "NPL", "WDL", "WMK", "WMT", | |
"WRS", "NPL", "WDL", "WMK", "WMT", "WRS", "NPL", "TRA", "WDL", | |
"WMC", "WMK", "WMT", "NPL", "TRA", "WDL", "WMC", "WMI", "WMK", | |
"TRA", "WDL", "WMB", "WMC", "WMI", "WMK", "WMT", "WMZ", "TON", | |
"TRA", "WDL", "WMB", "WMC", "WMI", "WMK", "WMT", "WMZ", "MAB", | |
"SBI", "TON", "TRA", "WDL", "WMB", "WMC", "WMH", "WMI", "WMK", | |
"WMT", "WMZ", "MAB", "TON", "TOR", "TRA", "TRO", "WDL", "WMB", | |
"WMC", "WMH", "WMI", "WMK", "WMT", "WMZ", "MAB", "SBI", "TI4", | |
"TMC", "TMI", "TOG", "TON", "TOR", "TOU", "TRA", "TRO", "TRU", | |
"WDL", "WMB", "WMC", "WMH", "WMI", "WMK", "WMT", "AMT", "SBI", | |
"TA3", "TI4", "TMC", "TOG", "TOI", "TON", "TOR", "TRA", "TRO", | |
"WDL", "WGL", "WMB", "WMC", "WMH", "WMK", "WMT", "PSA", "SBI", | |
"TA3", "TA4", "TAU", "TI4", "TIL", "TJO", "TMC", "TMI", "TOE", | |
"TOG", "TON", "TOR", "TRA", "TRO", "TRU", "WDL", "WGL", "WID", | |
"WMB", "WMC", "WMH", "WMK", "WMT", "AMT", "PSA", "TA3", "TA4", | |
"TAU", "TI4", "TIL", "TJO", "TLS", "TMC", "TMI", "TOE", "TOG", | |
"TON", "TOR", "TOU", "TRA", "TRO", "WDL", "WGL", "WID", "WMB", | |
"WMC", "WMH", "WMK", "WMT", "WTL", "TA3", "TA4", "TAU", "TBZ", | |
"TI4", "TJO", "TMC", "TMI", "TOE", "TOG", "TOM", "TON", "TOR", | |
"TOU", "TRA", "TRO", "TRU", "WDL", "WGL", "WMB", "WMC", "WMH", | |
"WMK", "WMT", "WTL", NA, "TI4", "TMC", "TMI", "TON", "TRO", "WDL", | |
"WGL", "WMC", "WMH", "WMK", "WMT"), count = c(24L, 2L, 28L, 28L, | |
29L, 2L, 1L, 27L, 17L, 32L, 2L, 8L, 45L, 27L, 9L, 1L, 13L, 6L, | |
79L, 9L, 31L, 6L, 4L, 4L, 68L, 38L, 1L, 21L, 6L, 76L, 7L, 35L, | |
4L, 30L, 1L, 1L, 2L, 21L, 60L, 10L, 34L, 9L, 21L, 6L, 2L, 2L, | |
3L, 4L, 18L, 90L, 3L, 35L, 10L, 4L, 25L, 39L, 4L, 2L, 29L, 9L, | |
12L, 10L, 87L, 10L, 31L, 73L, 20L, 26L, 22L, 3L, 2L, 1L, 2L, | |
27L, 1L, 2L, 49L, 21L, 1L, 12L, 5L, 1L, 140L, 36L, 54L, 63L, | |
22L, 14L, 30L, 46L, 4L, 2L, 4L, 38L, 6L, 1L, 61L, 9L, 8L, 3L, | |
121L, 11L, 17L, 61L, 32L, 18L, 34L, 2L, 4L, 14L, 6L, 8L, 15L, | |
21L, 1L, 48L, 1L, 3L, 10L, 44L, 6L, 28L, 16L, 8L, 149L, 15L, | |
8L, 32L, 54L, 36L, 16L, 32L, 1L, 1L, 42L, 1L, 4L, 12L, 11L, 13L, | |
6L, 43L, 19L, 3L, 16L, 58L, 6L, 3L, 31L, 10L, 113L, 14L, 8L, | |
37L, 48L, 44L, 26L, 29L, 2L, 31L, 1L, 7L, 12L, 17L, 12L, 63L, | |
31L, 6L, 8L, 3L, 59L, 8L, 4L, 34L, 7L, 2L, 138L, 36L, 5L, 43L, | |
64L, 42L, 43L, 20L, 6L, 2L, 19L, 19L, 46L, 4L, 43L, 6L, 11L, | |
25L, 10L, 12L)), class = "data.frame", row.names = c(NA, -196L | |
), .Names = c("year", "group", "count")) | |
gh <- ggplot(test2, aes(x=year, y = count, group = group, colour = group)) + | |
geom_point() + | |
geom_line() | |
gh | |
ggplotly(gh) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @cpsievert! Looks good now. Seriously good work here.