SYTYCD — where are these terrific dancers come from?

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

It’s Saturday midnight and I’m already sleepy. However, after several hours, I finally got this google geographic map embedded in my post. Aha!!!

This is about 20 finalists from the 9th season of So You Think You Can Dance. I count the states where they come from. Then plot the numbers on US map. Here shows the map.

SYTYCD2012
Data: dat • Chart ID: SYTYCD2012

Dancers’ names would show up when hovering on the map. Excuse me for not including Daniel Baker, the Australian ballet dancer. The code is also provided.

?View Code RSPLUS
 1 2 3 4 5 6 7 8 9 10 11  loc <- read.table("clipboard", sep = "\t", colClasses = "character") colnames(loc) <- c("name", "home") loc$home <- gsub("^\\w.+\\,\\s", "", loc$home) # remove cities state <- split(loc$name, f = loc$home) dat <- data.frame(sapply(state, paste, collapse = ", "), sapply(state, length)) colnames(dat) <- c("names", "count") dat$state <- rownames(dat) g.dat <- gvisGeoMap(dat, locationvar = "state", numvar = "count", hovervar = "names", options = list(region = "US"), chartid = "SYTYCD2012") cat(unlist(g.dat$html), file = "distribution.html") # map code used here