From dbdd9e93dfbf0de3363f191b3a86f8f9148ce2b4 Mon Sep 17 00:00:00 2001 From: Duncan Gillespie Date: Fri, 16 Dec 2022 11:29:15 +0000 Subject: [PATCH] remove requirement for stapmr package --- DESCRIPTION | 5 +++-- NAMESPACE | 2 +- R/AlcLags.R | 1 - R/RRAlc.R | 1 - R/RRFunc.R | 1 - R/RRtob.R | 1 - R/TobAlcInt.R | 1 - R/TobLags.R | 1 - R/fast_match.R | 30 ++++++++++++++++++++++++++++++ R/subgroupRisk.R | 1 - man/grapes-fin-grapes.Rd | 34 ++++++++++++++++++++++++++++++++++ 11 files changed, 68 insertions(+), 10 deletions(-) create mode 100644 R/fast_match.R create mode 100644 man/grapes-fin-grapes.Rd diff --git a/DESCRIPTION b/DESCRIPTION index da08f07..0d0cb6f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -49,9 +49,10 @@ Imports: crayon, TTR, Rfast, - stats + stats, + brew RdMacros: Rdpack, lifecycle VignetteBuilder: knitr -RoxygenNote: 7.2.1 +RoxygenNote: 7.2.3 Depends: R (>= 2.10) diff --git a/NAMESPACE b/NAMESPACE index c60b3b2..8ae683f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +export("%fin%") export(AlcBinge) export(AlcBinge_stapm) export(AlcLags) @@ -27,5 +28,4 @@ importFrom(data.table,rbindlist) importFrom(data.table,setDT) importFrom(data.table,setnames) importFrom(lifecycle,deprecate_soft) -importFrom(stapmr,"%fin%") importFrom(stats,ar) diff --git a/R/AlcLags.R b/R/AlcLags.R index a21263f..98874c3 100644 --- a/R/AlcLags.R +++ b/R/AlcLags.R @@ -17,7 +17,6 @@ #' on an individual's relative risk of disease has so far emerged. #' #' @importFrom data.table := setDT setnames data.table -#' @importFrom stapmr %fin% #' #' @references #' \insertRef{holmes2012temporal}{tobalcepi} diff --git a/R/RRAlc.R b/R/RRAlc.R index d24c59f..09a2f3b 100644 --- a/R/RRAlc.R +++ b/R/RRAlc.R @@ -39,7 +39,6 @@ #' @return Returns a numeric vector of each individual's relative risks for the alcohol related disease specified by "disease". #' #' @importFrom data.table := setDT setnames fifelse -#' @importFrom stapmr %fin% #' #' @export #' diff --git a/R/RRFunc.R b/R/RRFunc.R index 7bea5ab..c907180 100644 --- a/R/RRFunc.R +++ b/R/RRFunc.R @@ -112,7 +112,6 @@ #' #' #' @importFrom data.table := setDT setnames copy rbindlist -#' @importFrom stapmr %fin% #' #' @export #' diff --git a/R/RRtob.R b/R/RRtob.R index 0d53dba..3cf91bd 100644 --- a/R/RRtob.R +++ b/R/RRtob.R @@ -37,7 +37,6 @@ #' specified by "disease". #' #' @importFrom data.table := setDT setnames copy -#' @importFrom stapmr %fin% #' #' @export #' diff --git a/R/TobAlcInt.R b/R/TobAlcInt.R index 055fbe6..938c994 100644 --- a/R/TobAlcInt.R +++ b/R/TobAlcInt.R @@ -26,7 +26,6 @@ #' specified by "disease". #' #' @importFrom data.table := setDT setnames copy -#' @importFrom stapmr %fin% #' #' @export #' @references diff --git a/R/TobLags.R b/R/TobLags.R index 755f03f..b458998 100644 --- a/R/TobLags.R +++ b/R/TobLags.R @@ -37,7 +37,6 @@ #' on an individual's relative risk of disease has so far emerged. #' #' @importFrom data.table := setDT setnames data.table -#' @importFrom stapmr %fin% #' #' @export #' diff --git a/R/fast_match.R b/R/fast_match.R new file mode 100644 index 0000000..938ebc1 --- /dev/null +++ b/R/fast_match.R @@ -0,0 +1,30 @@ + +#' Fast matching +#' +#' A faster version of `%in%`. +#' +#' See [fastmatch::fmatch()] +#' +#' @param x values to be matched +#' @param table values to be matched against +#' +#' @return Logical indicating match or not +#' @export +#' +#' @keywords internal +#' +#' @examples +#' +#' \dontrun{ +#' +#' x %fin% y +#' +#' } +#' +#' +#' +`%fin%` <- function(x, table) { + + fastmatch::fmatch(x, table, nomatch = 0L) > 0L + +} \ No newline at end of file diff --git a/R/subgroupRisk.R b/R/subgroupRisk.R index 0f85f7c..5257455 100644 --- a/R/subgroupRisk.R +++ b/R/subgroupRisk.R @@ -31,7 +31,6 @@ #' @return Returns a data table containing the subgroup specific summaries for each disease. #' #' @importFrom data.table := setDT setnames copy .SD .N -#' @importFrom stapmr %fin% #' #' @export #' diff --git a/man/grapes-fin-grapes.Rd b/man/grapes-fin-grapes.Rd new file mode 100644 index 0000000..761642d --- /dev/null +++ b/man/grapes-fin-grapes.Rd @@ -0,0 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fast_match.R +\name{\%fin\%} +\alias{\%fin\%} +\title{Fast matching} +\usage{ +x \%fin\% table +} +\arguments{ +\item{x}{values to be matched} + +\item{table}{values to be matched against} +} +\value{ +Logical indicating match or not +} +\description{ +A faster version of `%in%`. +} +\details{ +See [fastmatch::fmatch()] +} +\examples{ + +\dontrun{ + +x \%fin\% y + +} + + + +} +\keyword{internal}