Skip to content

Instantly share code, notes, and snippets.

@corynissen
Last active August 29, 2015 14:02
Show Gist options
  • Save corynissen/1fa0ed73f55608bd613d to your computer and use it in GitHub Desktop.
Save corynissen/1fa0ed73f55608bd613d to your computer and use it in GitHub Desktop.
transform df to list for rCharts
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