Created
February 2, 2016 02:39
-
-
Save ozjimbob/b0fc0927e6c05ce8d0e6 to your computer and use it in GitHub Desktop.
R Dem Iowa Caucus Graph
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(rjson) | |
library(httr) | |
turl="https://iowadems-caucussitecdn-prod2.azureedge.net/api/statecandidateresults" | |
a=GET(turl) | |
arr=c(content(a)$StateResults[[1]]$WinPercentage,content(a)$StateResults[[2]]$WinPercentage,content(a)$StateResults[[3]]$WinPercentage) | |
nam=c(content(a)$StateResults[[1]]$Candidate$DisplayName,content(a)$StateResults[[2]]$Candidate$DisplayName,content(a)$StateResults[[3]]$Candidate$DisplayName) | |
colr=c(content(a)$StateResults[[1]]$Candidate$Color,content(a)$StateResults[[2]]$Candidate$Color,content(a)$StateResults[[3]]$Candidate$Color) | |
rar=round(arr,3)*100 | |
barplot(arr,names.arg=nam,col=colr) | |
text(1:3,0.3,rar,cex=2,pos=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment