Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

We (rOpenSci) have been writing code for R packages for a couple years, so it is time to take a look back at the data. What data you ask? The commits data from GitHub ~ data that records who did what and when.

Using the Github commits API we can gather data on who commited code to a Github repository, and when they did it. Then we can visualize this hitorical record.

### Install some functions for interacting with the Github API via R

``````install_github('sandbox', 'ropensci')

library(sandbox)
library(httr)
library(ggplot2)
library(scales)
library(reshape2)
library(bipartite)
library(doMC)
library(plyr)
library(ggthemes)
library(picante)

# And authenticate - pops open a page in your default browser, then tells
# you authentication was successful
github_auth()
``````

### Get all repos for an organization, here ropensci of course

``````ropensci_repos <- github_allrepos(userorg = "ropensci")
``````

### Get commits broken down in to additions and deletions, though below we just collapse them to all commits

``````registerDoMC(cores = 4)
github_commits_safe <- plyr::failwith(NULL, github_commits)
out <- llply(ropensci_repos, function(x) github_commits_safe("ropensci", x,
since = "2009-01-01T", limit = 500), .parallel = TRUE)
names(out) <- ropensci_repos
out2 <- compact(out)
outdf <- ldply(out2)
``````

### Plot commits by date and repo

``````outdf_subset <- outdf[!outdf\$.id %in% c("citeulike", "challenge", "docs", "ropensci-book",
"usecases", "textmine", "usgs", "ropenscitoolkit", "neotoma", "rEWDB", "rgauges",
"rodash", "ropensci.github.com", "ROAuth"), ]
outdf_subset\$.id <- tolower(outdf_subset\$.id)
outdf_subset <- ddply(outdf_subset, .(.id, date), summarise, value = sum(value))

mindates <- llply(unique(outdf_subset\$.id), function(x) min(outdf_subset[outdf_subset\$.id ==
x, "date"]))
names(mindates) <- unique(outdf_subset\$.id)
mindates <- sort(do.call(c, mindates))
outdf_subset\$.id <- factor(outdf_subset\$.id, levels = names(mindates))

ggplot(outdf_subset, aes(date, value, fill = .id)) +
geom_bar(stat = "identity", width = 0.5) +
geom_rangeframe(sides = "b", colour = "grey") +
theme_bw(base_size = 9) +
scale_x_date(labels = date_format("%Y"), breaks = date_breaks("year")) +
scale_y_log10() +
facet_grid(.id ~ .) +
labs(x = "", y = "") +
theme(axis.text.y = element_blank(),
axis.text.x = element_text(colour = "black"),
axis.ticks.y = element_blank(),
strip.text.y = element_text(angle = 0, size = 8, ),
strip.background = element_rect(size = 0),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
legend.text = element_text(size = 8),
legend.position = "none",
panel.border = element_blank())
`````` The plot above plots the sum of additions+deletions, and is sorted by the first commit date of reach repo, with the first being treebase, which wraps the Treebase API, and the most recent being rwbclimate, which wraps the World Blank climate data API.

You can see that some repos have recieved commits more or less consistently over their life time, while others have seen a little development here and there.

w

### In addition, there are quite a few people that have committed code now to rOpenSci repos, calling for a network vizualization of course.

``````outdf_network <- droplevels(outdf[!outdf\$.id %in% c("citeulike", "challenge",
"docs", "ropensci-book", "usecases", "textmine", "usgs", "ropenscitoolkit",
"retriever", "rodash", "ropensci.github.com", "ROAuth", "rgauges", "sandbox",
"rfna", "rmetadata", "rhindawi", "rpmc", "rpensoft", "ritis"), ])
casted <- dcast(outdf_network, .id + date + name ~ variable, fun.aggregate = length,
value.var = "value")
names(casted) <- "repo"
casted2 <- ddply(casted, .(repo, name), summarise, commits = sum(additions))
casted2 <- data.frame(repo = casted2\$repo, weight = casted2\$commits, name = casted2\$name)
mat <- sample2matrix(casted2)
plotweb(sortweb(mat, sort.order = "dec"), method = "normal", text.rot = 90,
adj.high = c(-0.3, 0), adj.low = c(1, -0.3), y.width.low = 0.05, y.width.high = 0.05,
ybig = 0.09, labsize = 0.7)
`````` The plot above shows repos on one side and contributors on the other. Some folks (the core rOpenSci team: cboettig, karthikram, emhart, and schamberlain) have committed quite a lot to many packages. We also have amny awesome contributors to our packages (some contributors and repos have been removed for clarity).

rOpenSci is truly a collaborative effort to develop tools for open science, so thanks to all our contributors – keep on forking, pull requesting, and commiting.
{"ft_lang_label":"__label__en","ft_lang_prob":0.6917417,"math_prob":0.9306847,"size":4832,"snap":"2020-34-2020-40","text_gpt3_token_len":1331,"char_repetition_ratio":0.11702568,"word_repetition_ratio":0.0608828,"special_character_ratio":0.27773178,"punctuation_ratio":0.2117117,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96564096,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,1,null,4,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-09-18T13:30:31Z\",\"WARC-Record-ID\":\"<urn:uuid:aabc4349-e5c6-4815-8441-90e0c1f6f81a>\",\"Content-Length\":\"88786\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:777e82ae-a35c-4ab0-a18d-0315a45fd315>\",\"WARC-Concurrent-To\":\"<urn:uuid:149513c8-ed4e-48bf-a7b1-4ac3337f9c38>\",\"WARC-IP-Address\":\"172.67.170.238\",\"WARC-Target-URI\":\"https://www.r-bloggers.com/visualizing-ropensci-collaboration/\",\"WARC-Payload-Digest\":\"sha1:BSYPIUSTPESPSE7Z3IB6AHZZWRIFCFAS\",\"WARC-Block-Digest\":\"sha1:ACJB6E4MVZWAGVRYQOPRLJ6J6HFZLTZC\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-40/CC-MAIN-2020-40_segments_1600400187899.11_warc_CC-MAIN-20200918124116-20200918154116-00613.warc.gz\"}"}