forked from USCbiostats/PM566
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
64 lines (49 loc) · 1.78 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
output: github_document
---
# Course Material for PM566
The PM566 course website is [here](https://elastic-khorana-70231e.netlify.app/). We will be using this website to share all course material including lecture slides, labs, and assignments.
Our class meets at 1pm every Wednesday. Zoom links for each lecture session are available in the course Blackboard.
# Latest week's cross reference
This is an example of web scrapping. We built this program to extract the
cross-reference links from a given GitHub issue, including details such as timestamp,
the user, and the commit message.
You can download the program [here](list_cross_ref.R)
```{r}
library(data.table)
library(stringr)
# API access
source("list_cross_ref_api.R", echo=FALSE)
```
```{r webscraping, message=FALSE, cache=TRUE}
library(httr)
# Setting up the token
if (file.exists(".github_app.R")) {
# See
# https://github.com/r-lib/httr/blob/cb4e20c9e0b38c0c020a8756db8db7a882288eaf/demo/oauth2-github.r
# For a detailed example
source(".github_app.R")
token <- oauth2.0_token(
endpoint = oauth_endpoints("github"),
app = github_app,
config = httr::config(connecttimeout = 60)
)
token <- httr::config(token = token)
} else {
token <- NULL
}
# Retrieving all the cross-reference information
ans <- list_cross_ref_api(
issue = 26,
config = c(httr::config(connecttimeout=60), token)
)
```
```{r printing-the-data, message=FALSE}
# Preparing to print using a nice format
ans[, user := sprintf("[%s](https://github.com/%s)", gsub("/.+", "", repo), repo)]
ans[, link := sprintf("[link](%s)", commit_url)]
setorder(ans, created_at)
# A more concise message
ans[, message := sprintf("%s (%s to this %s) (files: %s)", message, link, type, files)]
knitr::kable(ans[, .(created_at, user, message, type)])
```