mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 18:46:11 +01:00
(v1.7.1.9050) fix for as.mo
This commit is contained in:
parent
2bcf28281d
commit
8f5e5a3fc2
@ -1,5 +1,5 @@
|
||||
Package: AMR
|
||||
Version: 1.7.1.9049
|
||||
Version: 1.7.1.9050
|
||||
Date: 2021-10-05
|
||||
Title: Antimicrobial Resistance Data Analysis
|
||||
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
||||
|
2
NEWS.md
2
NEWS.md
@ -1,4 +1,4 @@
|
||||
# `AMR` 1.7.1.9049
|
||||
# `AMR` 1.7.1.9050
|
||||
## <small>Last updated: 5 October 2021</small>
|
||||
|
||||
### Breaking changes
|
||||
|
@ -138,15 +138,21 @@ atc_online_property <- function(atc_code,
|
||||
atc_url <- sub("%s", atc_code[i], atc_url, fixed = TRUE)
|
||||
|
||||
if (property == "groups") {
|
||||
tbl <- read_html(atc_url) %pm>%
|
||||
html_node("#content") %pm>%
|
||||
html_children() %pm>%
|
||||
html_node("a")
|
||||
out <- tryCatch(
|
||||
read_html(atc_url) %pm>%
|
||||
html_node("#content") %pm>%
|
||||
html_children() %pm>%
|
||||
html_node("a"),
|
||||
error = function(e) NULL)
|
||||
if (is.null(out)) {
|
||||
message_("Connection to ", atc_url, " failed.")
|
||||
return(rep(NA, length(atc_code)))
|
||||
}
|
||||
|
||||
# get URLS of items
|
||||
hrefs <- tbl %pm>% html_attr("href")
|
||||
hrefs <- out %pm>% html_attr("href")
|
||||
# get text of items
|
||||
texts <- tbl %pm>% html_text()
|
||||
texts <- out %pm>% html_text()
|
||||
# select only text items where URL like "code="
|
||||
texts <- texts[grepl("?code=", tolower(hrefs), fixed = TRUE)]
|
||||
# last one is antibiotics, skip it
|
||||
@ -154,15 +160,21 @@ atc_online_property <- function(atc_code,
|
||||
returnvalue <- c(list(texts), returnvalue)
|
||||
|
||||
} else {
|
||||
tbl <- read_html(atc_url) %pm>%
|
||||
html_nodes("table") %pm>%
|
||||
html_table(header = TRUE) %pm>%
|
||||
as.data.frame(stringsAsFactors = FALSE)
|
||||
out <- tryCatch(
|
||||
read_html(atc_url) %pm>%
|
||||
html_nodes("table") %pm>%
|
||||
html_table(header = TRUE) %pm>%
|
||||
as.data.frame(stringsAsFactors = FALSE),
|
||||
error = function(e) NULL)
|
||||
if (is.null(out)) {
|
||||
message_("Connection to ", atc_url, " failed.")
|
||||
return(rep(NA, length(atc_code)))
|
||||
}
|
||||
|
||||
# case insensitive column names
|
||||
colnames(tbl) <- gsub("^atc.*", "atc", tolower(colnames(tbl)))
|
||||
colnames(out) <- gsub("^atc.*", "atc", tolower(colnames(out)))
|
||||
|
||||
if (length(tbl) == 0) {
|
||||
if (length(out) == 0) {
|
||||
warning_("ATC not found: ", atc_code[i], ". Please check ", atc_url, ".", call = FALSE)
|
||||
returnvalue[i] <- NA
|
||||
next
|
||||
@ -170,15 +182,15 @@ atc_online_property <- function(atc_code,
|
||||
|
||||
if (property %in% c("atc", "name")) {
|
||||
# ATC and name are only in first row
|
||||
returnvalue[i] <- tbl[1, property]
|
||||
returnvalue[i] <- out[1, property]
|
||||
} else {
|
||||
if (!"adm.r" %in% colnames(tbl) | is.na(tbl[1, "adm.r"])) {
|
||||
if (!"adm.r" %in% colnames(out) | is.na(out[1, "adm.r"])) {
|
||||
returnvalue[i] <- NA
|
||||
next
|
||||
} else {
|
||||
for (j in seq_len(nrow(tbl))) {
|
||||
if (tbl[j, "adm.r"] == administration) {
|
||||
returnvalue[i] <- tbl[j, property]
|
||||
for (j in seq_len(nrow(out))) {
|
||||
if (out[j, "adm.r"] == administration) {
|
||||
returnvalue[i] <- out[j, property]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
R/mo.R
2
R/mo.R
@ -803,7 +803,7 @@ exec_as.mo <- function(x,
|
||||
perl = TRUE)), uncertainty = -1)
|
||||
next
|
||||
}
|
||||
if (x_backup_without_spp[i] %like_case% "haemoly.*strep") {
|
||||
if (x_backup_without_spp[i] %like_case% "ha?emoly.*strep") {
|
||||
# Haemolytic streptococci in different languages
|
||||
x[i] <- lookup(mo == "B_STRPT_HAEM", uncertainty = -1)
|
||||
next
|
||||
|
Binary file not shown.
@ -7,5 +7,5 @@ microorganisms.codes[which(microorganisms.codes$code == "ENT"), "mo"] <- as.mo("
|
||||
microorganisms.codes[which(microorganisms.codes$code == "STR"), "mo"] <- as.mo("streptococcus")
|
||||
microorganisms.codes[which(microorganisms.codes$code == "CDF"), "mo"] <- as.mo("clostridium difficile")
|
||||
microorganisms.codes[which(microorganisms.codes$code == "HA-"), "mo"] <- as.mo("haemophilus influenzae")
|
||||
usethis::use_data(microorganisms.codes, overwrite = TRUE)
|
||||
usethis::use_data(microorganisms.codes, overwrite = TRUE, version = 2)
|
||||
rm(microorganisms.codes)
|
||||
|
Binary file not shown.
@ -44,7 +44,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9049</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9050</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -92,7 +92,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9049</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9050</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -240,9 +240,9 @@
|
||||
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
||||
</div>
|
||||
|
||||
<div id="amr-1719049" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.7.1.9049">
|
||||
<a href="#amr-1719049" class="anchor" aria-hidden="true"></a><small> Unreleased </small><code>AMR</code> 1.7.1.9049</h1>
|
||||
<div id="amr-1719050" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.7.1.9050">
|
||||
<a href="#amr-1719050" class="anchor" aria-hidden="true"></a><small> Unreleased </small><code>AMR</code> 1.7.1.9050</h1>
|
||||
<div id="last-updated-5-october-2021" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#last-updated-5-october-2021" class="anchor" aria-hidden="true"></a><small>Last updated: 5 October 2021</small>
|
||||
|
@ -93,7 +93,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9040</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9050</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -92,7 +92,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9040</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9050</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -478,7 +478,7 @@
|
||||
<td>
|
||||
<p><code><a href="microorganisms.codes.html">microorganisms.codes</a></code> </p>
|
||||
</td>
|
||||
<td><p>Data Set with 5,605 Common Microorganism Codes</p></td>
|
||||
<td><p>Data Set with 5,604 Common Microorganism Codes</p></td>
|
||||
</tr><tr>
|
||||
|
||||
<td>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Data Set with 5,605 Common Microorganism Codes — microorganisms.codes • AMR (for R)</title>
|
||||
<title>Data Set with 5,604 Common Microorganism Codes — microorganisms.codes • AMR (for R)</title>
|
||||
|
||||
<!-- favicons -->
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
|
||||
@ -48,7 +48,7 @@
|
||||
<link href="../extra.css" rel="stylesheet">
|
||||
<script src="../extra.js"></script>
|
||||
|
||||
<meta property="og:title" content="Data Set with 5,605 Common Microorganism Codes — microorganisms.codes" />
|
||||
<meta property="og:title" content="Data Set with 5,604 Common Microorganism Codes — microorganisms.codes" />
|
||||
<meta property="og:description" content="A data set containing commonly used codes for microorganisms, from laboratory systems and WHONET. Define your own with set_mo_source(). They will all be searched when using as.mo() and consequently all the mo_* functions." />
|
||||
<meta property="og:image" content="https://msberends.github.io/AMR/logo.png" />
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
@ -93,7 +93,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9030</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9050</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -237,7 +237,7 @@
|
||||
<div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header">
|
||||
<h1>Data Set with 5,605 Common Microorganism Codes</h1>
|
||||
<h1>Data Set with 5,604 Common Microorganism Codes</h1>
|
||||
<small class="dont-index">Source: <a href='https://github.com/msberends/AMR/blob/master/R/data.R'><code>R/data.R</code></a></small>
|
||||
<div class="hidden name"><code>microorganisms.codes.Rd</code></div>
|
||||
</div>
|
||||
@ -251,7 +251,7 @@
|
||||
|
||||
<h2 class="hasAnchor" id="format"><a class="anchor" href="#format"></a>Format</h2>
|
||||
|
||||
<p>A <a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a> with 5,605 observations and 2 variables:</p><ul>
|
||||
<p>A <a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a> with 5,604 observations and 2 variables:</p><ul>
|
||||
<li><p><code>code</code><br /> Commonly used code of a microorganism</p></li>
|
||||
<li><p><code>mo</code><br /> ID of the microorganism in the <a href='microorganisms.html'>microorganisms</a> data set</p></li>
|
||||
</ul>
|
||||
@ -288,7 +288,7 @@ This package contains the complete taxonomic tree of almost all microorganisms (
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p><p>Developed by <a href="https://www.rug.nl/staff/m.s.berends/" class="external-link">Matthijs S. Berends</a>, <a href="https://www.rug.nl/staff/c.f.luz/" class="external-link">Christian F. Luz</a>, <a href="https://www.rug.nl/staff/a.w.friedrich/" class="external-link">Alexander W. Friedrich</a>, <a href="https://www.rug.nl/staff/b.sinha/" class="external-link">Bhanu N. M. Sinha</a>, <a href="https://www.rug.nl/staff/c.j.albers/" class="external-link">Casper J. Albers</a>, <a href="https://www.rug.nl/staff/c.glasner/" class="external-link">Corinna Glasner</a>.</p></p>
|
||||
<p><p>Developed by <a href="https://www.rug.nl/staff/m.s.berends/" class="external-link">Matthijs S. Berends</a>, Christian F. Luz.</p></p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
|
@ -93,7 +93,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9040</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9050</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -3,9 +3,9 @@
|
||||
\docType{data}
|
||||
\name{microorganisms.codes}
|
||||
\alias{microorganisms.codes}
|
||||
\title{Data Set with 5,605 Common Microorganism Codes}
|
||||
\title{Data Set with 5,604 Common Microorganism Codes}
|
||||
\format{
|
||||
A \link{data.frame} with 5,605 observations and 2 variables:
|
||||
A \link{data.frame} with 5,604 observations and 2 variables:
|
||||
\itemize{
|
||||
\item \code{code}\cr Commonly used code of a microorganism
|
||||
\item \code{mo}\cr ID of the microorganism in the \link{microorganisms} data set
|
||||
|
@ -37,8 +37,5 @@ if (identical(Sys.getenv("R_RUN_TINYTEST"), "true")) {
|
||||
color = FALSE)
|
||||
cat("SUMMARY:\n")
|
||||
print(summary(out))
|
||||
cat("WARNINGS:\n")
|
||||
print(warnings())
|
||||
cat(attributes(out)$duration, "\n")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user