SYTYCD — where are these terrific dancers come from?

[This article was first published on Tony's bubble universe » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
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
R version 2.15.0 (2012-03-30) • googleVis-0.2.15Google 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
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

To leave a comment for the author, please follow the link and comment on their blog: Tony's bubble universe » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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)