Graph a github user’s followers (and follower’s followers).
A few standard R libraries are required:
In this particular API call (an example of json returned – no API key is required for the Github API), the JSON data will represent a GitHub user’s (first thirty) followers. This implies the use of a graph to represent the data so the igraph library will be used as well.
With the RCurl and rjson libraries available, the json results can be retrieved and converted to an R list as follows:
o <- fromJSON(getURL('https://api.github.com/users/EzGraphs/followers'))
You can check the class for yourself using class(o) and view the length of the list using length(o)
To convert the results to the data frame where rows represent followers and columns represent attributes, unlist the results, transpose the results and cast as a data frame:
df <- as.data.frame(t(sapply(o, unlist)))
That is the basic process – the rest of the code is the details related to getting the data into the iGraph object which can then be rendered using plot, tkplot (show above) or rglplot.