1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-09 08:11:58 +02:00

use dplyr where available, new antibiogram() for WISCA, fixed Salmonella Typhi/Paratyphi

This commit is contained in:
2023-02-06 11:57:22 +01:00
parent 4b133d4c96
commit 9e99e66f01
69 changed files with 1670 additions and 650 deletions

View File

@ -139,9 +139,9 @@ atc_online_property <- function(atc_code,
if (property == "groups") {
out <- tryCatch(
read_html(atc_url) %pm>%
html_node("#content") %pm>%
html_children() %pm>%
read_html(atc_url) %>%
html_node("#content") %>%
html_children() %>%
html_node("a"),
error = function(e) NULL
)
@ -151,9 +151,9 @@ atc_online_property <- function(atc_code,
}
# get URLS of items
hrefs <- out %pm>% html_attr("href")
hrefs <- out %>% html_attr("href")
# get text of items
texts <- out %pm>% html_text()
texts <- out %>% html_text()
# select only text items where URL like "code="
texts <- texts[grepl("?code=", tolower(hrefs), fixed = TRUE)]
# last one is antibiotics, skip it
@ -161,9 +161,9 @@ atc_online_property <- function(atc_code,
returnvalue <- c(list(texts), returnvalue)
} else {
out <- tryCatch(
read_html(atc_url) %pm>%
html_nodes("table") %pm>%
html_table(header = TRUE) %pm>%
read_html(atc_url) %>%
html_nodes("table") %>%
html_table(header = TRUE) %>%
as.data.frame(stringsAsFactors = FALSE),
error = function(e) NULL
)