This is the structure of the github stats api data for a repository. I am using dplyr and tidy_json libraries to list the number of commits ("c") ,deletes("d"), lines of code added("a") and the corresponding week("w") for every user in a repository.
{
"total": 5,
"weeks": [
{
"w": 1428192000,
"a": 0,
"d": 0,
"c": 0
},
{
"w": 1428796800,
"a": 0,
"d": 0,
"c": 0
}
],
"author": {
"login": "ttuser1234",
"id": 111111111
}
},
{
"total": 18,
"weeks": [
{
"w": 1428192000,
"a": 212,
"d": 79,
"c": 5
},
{
"w": 1428796800,
"a": 146,
"d": 67,
"c": 1
}
],
"author": {
"login": "coder1234",
"id": 22222222
}
}
}
I am able to extract the weeks and author data separately, but then I am unable to join them together.
inp_file=read_json("The JSON file")
dat=as.tbl_json(inp_file)
dat%>%
enter_object("weeks") %>%
gather_array %>%
spread_values(week=jstring("w"),add=jstring("a"),del=jstring("d"),comm=jstring("c"))
enter_object("author") %>%
spread_values(handle=jstring("login"))
At no point am I able to jump from the author object to the weeks object to link the 2 of them. Is there any way I can do this? Appreciate any help.