-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.Rhistory
105 lines (105 loc) · 5.38 KB
/
.Rhistory
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
install.packages("svglite", repos="http://cran.us.r-project.org")
### ENVIRONMENT
if (!require(RefManageR)) {
install.packages("RefManageR", repos = "http://cran.us.r-project.org")
require(RefManageR)
}
if (!require(DescTools)) {
install.packages("DescTools", repos = "http://cran.us.r-project.org")
require(DescTools)
}
if (!require(stringr)) {
install.packages("stringr", repos = "http://cran.us.r-project.org")
require(stringr)
}
if (!require(lubridate)) {
install.packages("lubridate", repos = "http://cran.us.r-project.org")
require(lubridate)
}
BibOptions(check.entries = "warn",
sorting = "ydnt",
style = "markdown",
bib.style = "numeric",
max.names = Inf,
no.print.fields = c("url", "file", "keywords",
"issn", "abstract", "language", "pmid",
"copyright", "pmc"))
prepare_refs <- function(bib) {
void <- lapply(bib, function(ref) NoCite(ref))
refs <- capture.output(PrintBibliography(bib))
refs <- c("", refs)
refs <- SplitAt(refs,
which(nchar(refs) == 0))
sapply(
refs[2:length(refs)],
function(ref) {
ref <- paste0(ref, collapse = " ")
ref <- str_remove(ref, " <a(.*)a>")
ref <- str_remove(ref, "(?<=]])(.*?)\\)")
ref <- str_replace(ref, "\\\\textquotesingle", "'")
ref <- str_replace(ref, "\\\\textendash", "-")
ref <- str_replace(ref, "\\[\\[", "")
ref <- str_replace(ref, "\\]\\]", ".")
ref <- str_replace(ref, "\\\\\\\"\\\\i", "ï")
ref <- str_replace(ref, "S. Garnier", "**S. Garnier**")
ref
})
}
### DATA
preprints <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Preprints.bib")
journal_papers <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Journal-Papers.bib")
conference_papers <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Conference-Papers.bib")
book_chapters <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Book-Chapters.bib")
books <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Books.bib")
invited_talks <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Invited-talks.bib")
conference_abstracts <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Conference-Abstracts.bib")
preprints <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Preprints.bib")
journal_papers <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Journal-Papers.bib")
conference_papers <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Conference-Papers.bib")
book_chapters <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Book-Chapters.bib")
books <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Books.bib")
invited_talks <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Invited-talks.bib")
conference_abstracts <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Conference-Abstracts.bib")
preprints <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Preprints.bib")
journal_papers <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Journal-Papers.bib")
conference_papers <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Conference-Papers.bib")
book_chapters <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Book-Chapters.bib")
books <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Books.bib")
invited_talks <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Invited-talks.bib")
conference_abstracts <- ReadBib("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Conference-Abstracts.bib")
### PREPRINTS REFERENCES
preprints_refs <- prepare_refs(preprints)
scholar_page <- readLines("publications/index.md")
warnings()
setwd("~/Library/CloudStorage/[email protected]/My Drive/Work/web/swarmlab/scripts")
setwd("/Users/simon/Library/CloudStorage/[email protected]/My Drive/Work/web/swarmlab")
### PREPRINTS REFERENCES
preprints_refs <- prepare_refs(preprints)
warnings()
### PREPRINTS REFERENCES
preprints_refs <- prepare_refs(preprints)
scholar_page <- readLines("publications/index.md")
start <- grep("#### Preprints under Review", scholar_page) - 1
end <- min(which(scholar_page == "---")[which(scholar_page == "---") > start])
scholar_page <- scholar_page[-(start + 1):-(end - 1)]
section <- paste0("#### Preprints under Review (Last updated ",
format(today(), "%b %d, %Y"), ")")
out <- c(scholar_page[1:start], "", section, "", preprints_refs, "",
scholar_page[(start + 1):length(scholar_page)])
out
### PREPRINTS REFERENCES
preprints_refs <- prepare_refs(preprints)
scholar_page <- readLines("publications/index.md")
start <- grep("#### Preprints under Review", scholar_page) - 1
end <- min(which(scholar_page == "---")[which(scholar_page == "---") > start])
scholar_page <- scholar_page[-(start + 1):-(end - 1)]
section <- paste0("#### Preprints under Review (Last updated ",
format(today(), "%b %d, %Y"), ")")
scholar_page
section <- paste0("#### Preprints under Review (Last updated ",
format(today(), "%b %d, %Y"), ")")
section
preprints_refs
out <- c(scholar_page[1:start], "", section, "", preprints_refs, "",
scholar_page[(start + 1):length(scholar_page)])
out