SYTYCD — where are these terrific dancers come from?

June 29, 2012

(This article was first published on Tony's bubble universe » R, and kindly contributed to R-bloggers)

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.

Data: dat • Chart ID: SYTYCD2012

R version 2.15.0 (2012-03-30) • googleVis-0.2.15
Google Terms of UseData Policy

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
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

To leave a comment for the author, please follow the link and comment on their blog: Tony's bubble universe » R. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , ,

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)