Skip to content

Instantly share code, notes, and snippets.

@bhive01
Last active March 8, 2016 02:26
Show Gist options
  • Save bhive01/173f2c7011f82e94bc49 to your computer and use it in GitHub Desktop.
Save bhive01/173f2c7011f82e94bc49 to your computer and use it in GitHub Desktop.
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)
@bhive01
Copy link
Author

bhive01 commented Mar 7, 2016

Almost forgot:

Session info ----------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.2.3 (2015-12-10)
 system   x86_64, darwin13.4.0        
 ui       AQUA                        
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       America/Los_Angeles         
 date     2016-03-07                  

Packages --------------------------------------------------------------------------------------------------
 package     * version     date       source                               
 assertthat    0.1         2013-12-06 CRAN (R 3.2.0)                       
 base64enc     0.1-3       2015-07-28 CRAN (R 3.2.0)                       
 colorspace    1.2-6       2015-03-11 CRAN (R 3.2.0)                       
 DBI           0.3.1       2014-09-24 CRAN (R 3.2.0)                       
 devtools      1.10.0.9000 2016-02-26 Github (hadley/devtools@b6a23be)     
 digest        0.6.9       2016-01-08 CRAN (R 3.2.3)                       
 dplyr       * 0.4.3       2015-09-01 CRAN (R 3.2.0)                       
 ggplot2     * 2.1.0       2016-03-01 CRAN (R 3.2.4)                       
 gridExtra     2.2.1       2016-02-29 CRAN (R 3.2.4)                       
 gtable        0.2.0.9000  2016-02-26 Github (hadley/gtable@0ed36a4)       
 htmltools     0.3         2015-12-29 CRAN (R 3.2.3)                       
 htmlwidgets   0.6.1       2016-03-07 Github (ramnathv/htmlwidgets@2e4ad57)
 httr          1.1.0       2016-01-28 CRAN (R 3.2.3)                       
 jsonlite      0.9.19      2015-11-28 CRAN (R 3.2.2)                       
 labeling      0.3         2014-08-23 CRAN (R 3.2.0)                       
 magrittr      1.5         2014-11-22 CRAN (R 3.2.0)                       
 memoise       1.0.0       2016-01-29 CRAN (R 3.2.3)                       
 munsell       0.4.3       2016-02-13 CRAN (R 3.2.3)                       
 plotly      * 2.4.4       2016-02-19 Github (ropensci/plotly@b79e9d2)     
 plyr          1.8.3.9000  2015-10-16 Github (hadley/plyr@9d8294e)         
 R6            2.1.2       2016-01-26 CRAN (R 3.2.3)                       
 Rcpp          0.12.3      2016-01-10 CRAN (R 3.2.3)                       
 scales        0.4.0.9000  2016-02-26 Github (hadley/scales@646b6a4)       
 viridis       0.3.3       2016-03-07 Github (sjmgarnier/viridis@60a9783)  
 withr         1.0.1       2016-02-04 CRAN (R 3.2.3)                       
 yaml          2.1.13      2014-06-12 CRAN (R 3.2.0) 

@cpsievert
Copy link

I just merged a major update. Try reinstalling from github

@bhive01
Copy link
Author

bhive01 commented Mar 8, 2016

Thanks @cpsievert! Looks good now. Seriously good work here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment