Skip to content

Commit 9aad0c9

Browse files
committed
Adding final lecture
1 parent 5f575ec commit 9aad0c9

File tree

5 files changed

+3434
-1
lines changed

5 files changed

+3434
-1
lines changed

lectures/99-autoreport/README.qmd

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
format: gfm
3+
---
4+
5+
![GitHub last commit](https://img.shields.io/github/last-commit/UofUEpiBio/PHS-7045-egga)
6+
7+
# Latest papers on Agent-Based Modeling in PubMed
8+
9+
This repository is an *Example using GitHub Actions* \[egge\] for the Advanced Programming with R class. The project consists of a quarto document updated once a week or whenever there's a push or pull request. It performs a search on PubMed looking for the [latest papers about Agent-Based Models](https://pubmed.ncbi.nlm.nih.gov/?term=agent-based+model&sort=date){target="_blank"}. The last update was on `r Sys.time()`.
10+
11+
```{r}
12+
#| label: data-extract
13+
#| echo: false
14+
library(xml2)
15+
16+
doc <- read_html("https://pubmed.ncbi.nlm.nih.gov/?term=agent-based+model&sort=date")
17+
18+
# Titles
19+
titles <- xml_find_all(doc, xpath = '//*[@class="docsum-title"]')
20+
titles <- xml_text(titles)
21+
titles <- trimws(titles, which = "both")
22+
23+
# Authors
24+
authors <- xml_find_all(doc, xpath = '//*[@class="docsum-authors full-authors"]')
25+
authors <- xml_text(authors)
26+
27+
# Citation
28+
citation <- xml_find_all(doc, xpath = '//*[contains(@class, "full-journal-citation")]')
29+
citation <- xml_text(citation)
30+
31+
# Abstract
32+
abstract <- xml_find_all(doc, xpath = '//*[@class="full-view-snippet"]')
33+
abstract <- xml_text(abstract)
34+
abstract <- trimws(abstract, which = "both") #Removing trailing and leading space
35+
```
36+
37+
38+
```{r}
39+
#| results: asis
40+
#| label: printing
41+
#| echo: false
42+
for (i in 1:length(titles)) {
43+
44+
cat(sprintf("%i. **%s**\n\n %s\n\n %s\n\n >%s\n\n", i, titles[i], authors[i], citation[i], abstract[i]))
45+
46+
}
47+
```
48+
49+
150 KB
Loading

0 commit comments

Comments
 (0)