-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.R
68 lines (58 loc) · 1.48 KB
/
functions.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
63
64
65
66
67
68
library(pander)
library(stringr)
library(dplyr)
library(googlesheets4)
library(lubridate)
library(kableExtra)
gs4_deauth()
gscholar_stats <- function(url) {
cites <- get_cites(url)
return(paste(
'Citations:', cites$citations, '|',
'h-index:', cites$hindex, '|',
'i10-index:', cites$i10index
))
}
get_cites <- function(url) {
html <- xml2::read_html(url)
node <- rvest::html_nodes(html, xpath='//*[@id="gsc_rsb_st"]')
cites_df <- rvest::html_table(node)[[1]]
cites <- data.frame(t(as.data.frame(cites_df)[,2]))
names(cites) <- c('citations', 'hindex', 'i10index')
return(cites)
}
get_cv_sheet <- function(sheet) {
return(read_sheet(
ss = 'https://docs.google.com/spreadsheets/d/1yEYPdjQNqIw_lrOjUPDKjx9wMfzTeYrcdrtSDRj6Zhw/edit',
sheet = sheet
))
}
make_ordered_list <- function(x) {
return(pandoc.list(x, style = 'ordered'))
}
make_bullet_list <- function(x) {
return(pandoc.list(x, style = 'bullet'))
}
make_ordered_list_filtered <- function(df, cat) {
return(df %>%
filter(category == {{cat}}) %>%
mutate(
citation = str_replace_all(
citation,
"\\\\\\*(\\w+),",
"\\\\*\\\\underline{\\1},"
)
) %>%
pull(citation) %>%
make_ordered_list()
)
}
na_to_space <- function(x) {
return(ifelse(is.na(x), '', x))
}
enquote <- function(x) {
return(paste0('"', x, '"'))
}
markdown_url <- function(url) {
return(paste0('[', url, '](', url,')'))
}