From 35963ca3dc890daef8140678b7946decefc6a297 Mon Sep 17 00:00:00 2001 From: Matthijs Berends Date: Sat, 24 Feb 2024 18:51:37 +0100 Subject: [PATCH] vctrs fix --- DESCRIPTION | 2 +- NEWS.md | 2 +- R/vctrs.R | 30 ++++++++++++++++-------------- R/zzz.R | 8 ++++---- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 73f0c3bf..0838f154 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 2.1.1.9007 +Version: 2.1.1.9008 Date: 2024-02-24 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index a0e8937c..6b0b1c92 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 2.1.1.9007 +# AMR 2.1.1.9008 *(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support!)* diff --git a/R/vctrs.R b/R/vctrs.R index fb318c9d..e3737ff8 100755 --- a/R/vctrs.R +++ b/R/vctrs.R @@ -34,29 +34,31 @@ # see https://github.com/tidyverse/dplyr/issues/5955 why this is required -# S3: ab_selector -vec_ptype2.ab_selector.default <- function (x, y, ..., x_arg = "", y_arg = "") { +# S3: ab_selector ---- +# this does not need a .default method since it's used internally only +vec_ptype2.character.ab_selector <- function(x, y, ...) { x } -vec_ptype2.ab_selector.ab_selector <- function(x, y, ...) { - x +vec_ptype2.ab_selector.character <- function(x, y, ...) { + y } vec_cast.character.ab_selector <- function(x, to, ...) { unclass(x) } -# S3: ab_selector_any_all -vec_ptype2.ab_selector_any_all.default <- function (x, y, ..., x_arg = "", y_arg = "") { +# S3: ab_selector_any_all ---- +# this does not need a .default method since it's used internally only +vec_ptype2.logical.ab_selector_any_all <- function(x, y, ...) { x } -vec_ptype2.ab_selector_any_all.ab_selector_any_all <- function(x, y, ...) { - x +vec_ptype2.ab_selector_any_all.logical <- function(x, y, ...) { + y } vec_cast.logical.ab_selector_any_all <- function(x, to, ...) { unclass(x) } -# S3: ab +# S3: ab ---- vec_ptype2.ab.default <- function (x, y, ..., x_arg = "", y_arg = "") { x } @@ -70,7 +72,7 @@ vec_cast.ab.character <- function(x, to, ...) { return_after_integrity_check(x, "antimicrobial drug code", as.character(AMR_env$AB_lookup$ab)) } -# S3: av +# S3: av ---- vec_ptype2.av.default <- function (x, y, ..., x_arg = "", y_arg = "") { x } @@ -84,7 +86,7 @@ vec_cast.av.character <- function(x, to, ...) { return_after_integrity_check(x, "antiviral drug code", as.character(AMR_env$AV_lookup$av)) } -# S3: mo +# S3: mo ---- vec_ptype2.mo.default <- function (x, y, ..., x_arg = "", y_arg = "") { x } @@ -99,7 +101,7 @@ vec_cast.mo.character <- function(x, to, ...) { return_after_integrity_check(x, "microorganism code", as.character(AMR_env$MO_lookup$mo)) } -# S3: disk +# S3: disk ---- vec_ptype2.disk.default <- function (x, y, ..., x_arg = "", y_arg = "") { x } @@ -125,7 +127,7 @@ vec_cast.disk.character <- function(x, to, ...) { as.disk(x) } -# S3: mic +# S3: mic ---- vec_ptype2.mic.default <- function (x, y, ..., x_arg = "", y_arg = "") { x } @@ -157,7 +159,7 @@ vec_arith.mic <- function(op, x, y, ...) { vctrs::vec_arith(op, as.double(x), as.double(y)) } -# S3: sir +# S3: sir ---- vec_ptype2.sir.default <- function (x, y, ..., x_arg = "", y_arg = "") { x } diff --git a/R/zzz.R b/R/zzz.R index 054b0329..ea9d093e 100755 --- a/R/zzz.R +++ b/R/zzz.R @@ -133,12 +133,12 @@ if (pkg_is_available("cli")) { # Support vctrs package for use in e.g. dplyr verbs # NOTE 2024-02-22 this is the right way - it should be 2 S3 classes in the second argument # S3: ab_selector - s3_register("vctrs::vec_ptype2", "ab_selector.default") - s3_register("vctrs::vec_ptype2", "ab_selector.ab_selector") + s3_register("vctrs::vec_ptype2", "character.ab_selector") + s3_register("vctrs::vec_ptype2", "ab_selector.character") s3_register("vctrs::vec_cast", "character.ab_selector") # S3: ab_selector_any_all - s3_register("vctrs::vec_ptype2", "ab_selector_any_all.default") - s3_register("vctrs::vec_ptype2", "ab_selector_any_all.ab_selector_any_all") + s3_register("vctrs::vec_ptype2", "logical.ab_selector_any_all") + s3_register("vctrs::vec_ptype2", "ab_selector_any_all.logical") s3_register("vctrs::vec_cast", "logical.ab_selector_any_all") # S3: ab s3_register("vctrs::vec_ptype2", "ab.default")