Last active
August 29, 2015 14:06
-
-
Save renkun-ken/85aa6dff500196f82bb1 to your computer and use it in GitHub Desktop.
Where do R's supportive members mainly come from?
This file contains hidden or 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(pipeR) # https://github.com/renkun-ken/pipeR | |
library(rlist) # https://github.com/renkun-ken/rlist | |
library(rvest) # https://github.com/hadley/rvest | |
library(stringr) # https://github.com/hadley/stringr | |
# please ensure rvest is the latest dev version | |
Pipe("http://www.r-project.org/foundation/memberlist.html")$ | |
html()$ # use xpath to scrape the name list | |
html_nodes(xpath = "//table[2]//td//text() | //table[3]//td//text()")$ | |
html_text(trim = TRUE)$ | |
str_match_all(".+\\s\\((.+)\\)")$ # select their nations | |
list.rbind()[,2]$ # combine to matrix and select nation column | |
str_split(", ")$ # some members have multiple nationalities | |
unlist()$ | |
table()$ | |
sort(decreasing = TRUE)$ | |
head(10)$ | |
barplot(main = "Where do R's supportive members mainly come from?") |
Thanks very much
Yes Ari has done a good job on choroplethr and it works in shiny and rmarkdown which I don't believe some of the attractive rMaps options do. There is also a prob with country aliases e.g UK in my example
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you really want to maintain the mainstream pipeline (plotting the chart) and branch it with a map, the following code works:
This requires
pipeR
v0.5 to allow->
for assignment or otherwise you can only use less elegant=
:)