Skip to content

Instantly share code, notes, and snippets.

@romainfrancois
Forked from hadley/dplyr-issues.R
Created November 2, 2015 12:34
Show Gist options
  • Save romainfrancois/3d9418b3a0b22089132e to your computer and use it in GitHub Desktop.
Save romainfrancois/3d9418b3a0b22089132e to your computer and use it in GitHub Desktop.
library(purrr)
library(github) # install_github("cscheid/rgithub")
library(dplyr)
library(stringr)
library(magrittr)
# Download issues ---------------------------------------------------------
ctx <- interactive.login("56b637a5baffac62cad9", "8e107541ae1791259e9987d544ca568633da2ebf")
issues1 <- get.repository.issues("hadley", "dplyr", per_page = 100)
issues2 <- get.repository.issues("hadley", "dplyr", per_page = 100, page = 2)
issues <- c(issues1$content, issues2$content)
# Convert into a data frame -----------------------------------------------
`%||%` <- function(x, y) if (is.null(x)) y else x
str_trunc <- function(x, n = 50, ellipsis = "...") {
too_long <- str_length(x) > n
x[too_long] <- str_c(str_sub(x[too_long], 1, n - str_length(ellipsis)), ellipsis)
x
}
num <- issues %>% map_int("number")
title <- issues %>% map_chr("title")
labels <- issues %>% map("labels") %>% map_chr(
. %>% map("name") %>% flatten() %>%
setdiff(c("enhancement", "bug")) %>%
paste0(collapse = ", ")
)
milestone <- issues %>% map(c("milestone", "title")) %>% map_chr(~. %||% "")
is_pr <- issues %>% map(c("pull_request", "url")) %>% map_lgl(~!is.null(.))
dplyr_issues <- data_frame(num, title, labels, milestone, is_pr) %>%
filter(milestone == "0.5", !is_pr) %>%
select(-milestone, -is_pr) %>%
mutate(title = str_trunc(title, 70))
# dplyr_issues %$%
# paste0("* ", format(num), ": ", title, " [", labels, "]") %>%
# cat(file = "~/desktop/dplyr-issues.md", sep = "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment