Last active
August 29, 2015 14:02
-
-
Save corynissen/1fa0ed73f55608bd613d to your computer and use it in GitHub Desktop.
transform df to list for rCharts
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(RColorBrewer) | |
# max of 12 cats in colorbrewer, gotta add 6 more | |
colors <- brewer.pal(12, "Paired") | |
colors <- c(colors, "#050505", "#FAF20F", "#FA28EC", "#24E3CD", "#DAFAD4", "#6B6C6E") | |
df2 <- df | |
routes <- unique(df2$route) | |
df2$color <- colors[match(df2$route, routes)] | |
df2$popup <- paste0("<p>Pick up time: ", df$pu.time, | |
"<br>Drop off time: ", df$do.time, | |
"<br>", df$stop, | |
"<br>Route Number: ", str_extract(df2$route, "[0-9]+"), "</p>") | |
tmp.data <- apply(df2, 1, as.list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment