-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetup.R
62 lines (50 loc) · 1.8 KB
/
setup.R
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
# Set basic things up ----
library(knitr)
library(dplyr)
library(readr)
library(tidyr)
# library(car)
# knitr::opts_knit$set(unnamed.chunk.label = "chunk_")
knitr::opts_chunk$set(
cache = TRUE,
# error = FALSE,
# warning = FALSE,
# message = FALSE,
fig.width = 8,
fig.asp = 1/1.618,
fig.align = "center",
out.width = "90%",
comment = "#>",
tidy = FALSE # "formatR",
# tidy.opts = list(blank = FALSE, width.cutoff = 80)
)
# Read data used throughout tutorial ----
qmsurvey <- read_rds("data/qm_survey_ss2017.rds")
gotdeaths <- read_csv("data/got_deaths.csv", col_types = cols())
participation <- read_rds("data/participation.rds")
gotdeaths_books <- read_csv("data/got_character-deaths.csv", col_types = cols())
# Function to display latest commits ----
get_latest_commit <- function(count = 3) {
date <- url <- avatar <- author_url <- msg <- NULL
gh_status <- httr::status_code(purrr::safely(httr::GET)(("https://api.github.com"))$result)
if (gh_status != "200") {
return("(No recent commits to show)")
}
index <- seq_len(count)
commits <- jsonlite::fromJSON("https://api.github.com/repos/tadaadata/r-intro-book/commits")
name <- commits$commit$author$name[index]
name <- ifelse(name == "jemus42", "Lukas", name)
name <- ifelse(name == "MarauderPixie", "Tobi", name)
date <- format(lubridate::ymd_hms(commits$commit$author$date[index],
tz = "Europe/Berlin", quiet = TRUE), "%F %H:%M")
url <- commits$html_url[index]
avatar <- commits$author$avatar_url[index]
author_url <- commits$author$html_url[index]
msg <- commits$commit$message[index]
tibble(
Datum = date,
Committer = name,
Message = msg
) %>%
kable(caption = "Letzte Änderungen", booktabs = TRUE)
}