Code for list reactions for issues of a reposity. Inspired from the Yihui's blog post.
dependencies <- c("dplyr", "purrr", "httr", "stringr", "jsonlite") for (pkg in dependencies) { if (!require(pkg, character.only = TRUE)) install.packages(pkg, character.only = TRUE) } for (file in list.files("R")) { cat(file, "\n") source(file.path("R", file)) }
As a default, GitHub only allows 60
API calls per hour for anonymous users, and the GITHUB_PAT
environment variable is used. I highly recommend to Create your own pat and set env GITHUB_PAT
, for increasing the unauthenticated rate limit to 5000 for OAuth.
Sys.setenv(GITHUB_PAT = "your_pat")
List reactions of an issue and its comment of a given repository:
# taken the rstudio/rmakrdown for example reactions <- github_repo_issue_reactions("rstudio/rmarkdown")
There are 46 opened issues in rstudio/ramrkdown
, var comment_count
indicates the count of comments of an issue
grouped_reactions <- dplyr::group_by(reactions, issue_number) %>% dplyr::summarise(comment_count = n() - 1L) grouped_reactions
As mentioned in the blog post, the most upvoted reactions is comment 320504839
of issue 1020
most_upvoted <- dplyr::filter(reactions, `+1` == max(`+1`)) str(most_upvoted) # we can view the details in the browser browseURL(most_upvoted$html_url)
Requests that return multiple items will be paginated to 30
items by default.
Note: While we set the page size to the maximum 100
for auto pagination, and seek to not overstep your rate limit (5000 request per hour, once the
GITHUB_PAT is setted as your personal token).
Unfortunately,the gh package, a minimalistic GitHub API client in R, came into my eyes just after finish these codes.
If necessary I'll rewrite my codes rely on gh for the lowlevel stuff later.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.