-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfull-table.Rmd
92 lines (73 loc) · 1.97 KB
/
full-table.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
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
---
output: github_document
title: Full table
---
This repository compiles information about epidemics modeling. The goal is
to provide a centralized and standardized way of adding annotated data entries
about methods, software, data, and scientific articles on the subject.
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(yaml)
library(data.table)
if (file.exists("functions.R")) {
source("functions.R")
} else
source("docs/functions.R")
```
```{r results='asis'}
menu_maker("")
```
```{r listing-reading, warning=FALSE}
fns <- list.files("../data", full.names = TRUE) |> sort()
fns <- fns[!grepl("README[.]md$", fns)]
headers <- get_headers(fns)
```
```{r create-tables}
tab <- lapply(headers, \(f) {
title <- f$`title-paper`
software <- f$`software-package`
doi <- f$doi
# Processing software tools
software <- if (length(software)) {
sprintf(
"[%s (%s)](%s)",
sapply(software, "[[", 2),
sapply(software, "[[", 1),
sapply(software, "[[", 3)
) |> paste(collapse = ", ")
} else
""
# Processing DOI
doi <- if (length(doi)) {
sprintf("[%s](https://doi.org/%s)", doi, doi)
} else
""
# Processing keywords
keywords <- f$keywords
keywords <- if (length(keywords)) {
keywords <- tolower(keywords)
linker(keywords, paste0("**`", keywords, "`**"), "by-keyword.md") |>
paste(collapse = ", ")
} else
""
# Putting all together
data.table(
title = null2empty(title),
software = software,
doi = null2empty(doi),
keywords = keywords
)
}) |> rbindlist(fill = TRUE)
# Adding a link
tab[, title := sprintf(
"%s (**[link](entries/%s)**)",
title,
gsub("../data/", "", names(headers))
)]
tab[, keywords := tolower(keywords)]
tab |> knitr::kable(row.names = FALSE)
```
```{r echo = FALSE}
json <- '{"schemaVersion": "1", "label": "Entries", "message": "%i", "color": "green"}'
cat(sprintf(json, nrow(tab)), file = "info/entries.json")
```