From 355b62683e560bd7cb431f6657e769c847c519b1 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Tue, 18 Aug 2026 23:10:54 +0000 Subject: [PATCH 1/2] Move data.table from Depends to Imports --- DESCRIPTION | 4 ++-- NAMESPACE | 24 ++++++++++++++++++- R/intervalaverage_functions.R | 5 +++- R/intervalintersect.r | 1 + R/isoverlapping.R | 1 + man/CJ.dt.Rd | 1 + man/intervalaverage.Rd | 1 + man/intervalintersect.Rd | 1 + man/is.overlapping.Rd | 1 + man/isolateoverlaps.Rd | 1 + tests/testthat.R | 1 + tests/testthat/setup.R | 1 + vignettes/intervalaverage-advanced.Rmd | 1 + vignettes/intervalaverage-intro.Rmd | 2 ++ .../intervalaverage-technicaloverview.Rmd | 1 + 15 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 tests/testthat/setup.R diff --git a/DESCRIPTION b/DESCRIPTION index c30d5be..6fa8dbb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,10 +20,8 @@ License: GPL-3 Encoding: UTF-8 LazyData: true Depends: - data.table (>= 1.12.8), R (>= 2.10) Roxygen: list(markdown = TRUE) -RoxygenNote: 7.1.2 Suggests: knitr, rmarkdown, @@ -32,5 +30,7 @@ VignetteBuilder: knitr LinkingTo: Rcpp Imports: + data.table (>= 1.12.8), Rcpp URL: https://kaufman-lab.github.io/intervalaverage/ +Config/roxygen2/version: 8.0.0 diff --git a/NAMESPACE b/NAMESPACE index 4b718a9..9ea0f35 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,6 +5,28 @@ export(intervalaverage) export(intervalintersect) export(is.overlapping) export(isolateoverlaps) -import(data.table) importFrom(Rcpp,sourceCpp) +importFrom(data.table,":=") +importFrom(data.table,.EACHI) +importFrom(data.table,.SD) +importFrom(data.table,as.IDate) +importFrom(data.table,as.data.table) +importFrom(data.table,copy) +importFrom(data.table,data.table) +importFrom(data.table,fifelse) +importFrom(data.table,foverlaps) +importFrom(data.table,is.data.table) +importFrom(data.table,key) +importFrom(data.table,melt) +importFrom(data.table,rbindlist) +importFrom(data.table,rleid) +importFrom(data.table,set) +importFrom(data.table,setcolorder) +importFrom(data.table,setindex) +importFrom(data.table,setkey) +importFrom(data.table,setkeyv) +importFrom(data.table,setnames) +importFrom(data.table,setorder) +importFrom(data.table,setorderv) +importFrom(data.table,shift) useDynLib(intervalaverage, .registration = TRUE) diff --git a/R/intervalaverage_functions.R b/R/intervalaverage_functions.R index eff6f26..e35036a 100644 --- a/R/intervalaverage_functions.R +++ b/R/intervalaverage_functions.R @@ -25,6 +25,7 @@ create_unused_name <- function(x,reserved_cols){ #' @param groups a character vector corresponding to #' column names of grouping vars in all of the data.tables #' @examples +#' library(data.table) #' #' CJ.dt(data.table(c(1,2,2),c(1,1,1)),data.table(c("a","b"),c("c","d"))) #' #If you want to expand x to unique values of a non-unique columns in y #' x <- data.table(c(1,2,3),c("a","b","b")) @@ -32,7 +33,7 @@ create_unused_name <- function(x,reserved_cols){ #' z <- CJ.dt(x, y[,list(id=unique(id))]) #' #if you want to merge this back to y #' y[z,on="id",allow.cartesian=TRUE] #or z[y,on="id",allow.cartesian=TRUE] -#' @import data.table +#' @importFrom data.table := .EACHI .SD as.data.table as.IDate copy data.table fifelse foverlaps is.data.table key melt rbindlist rleid set setcolorder setindex setkey setkeyv setnames setorder setorderv shift #' @export CJ.dt <- function(...,groups=NULL) { l = list(...) @@ -186,6 +187,7 @@ CJ.dt <- function(...,groups=NULL) { #' concurrent run of times (or whatever the units of intervals are) for which that value variable is missing #' (either structurally missing ie--no intervals at all in x--or missing with an NA or any combination thereof). #' @examples +#' library(data.table) #'x <- data.table(start=seq(1L,by=7L,length=6), #' end=seq(7L,by=7L,length=6), #' pm25=c(10,12,8,14,22,18)) @@ -741,6 +743,7 @@ interval_weighted_avg_slow_f <- function(x, #' values of \code{group_vars} #' #' @examples +#' library(data.table) #'set.seed(23) #'x2 <- data.table(addr_id=rep(1:4,each=3), #' exposure_start=rep(c(1L,7L,14L),times=4), diff --git a/R/intervalintersect.r b/R/intervalintersect.r index 328b041..3d03a30 100644 --- a/R/intervalintersect.r +++ b/R/intervalintersect.r @@ -52,6 +52,7 @@ #' for how naming conflicts are dealt with. #' @seealso \code{\link{is.overlapping}} To test if a table contains overlapping intervals within values of \code{group_vars} #' @examples +#' library(data.table) #'set.seed(42) #'y <- data.table(addr_id=c(1,2,2,3,5), #'ppt_id=c(1,1,1,2,2), diff --git a/R/isoverlapping.R b/R/isoverlapping.R index eb60453..df0df36 100644 --- a/R/isoverlapping.R +++ b/R/isoverlapping.R @@ -34,6 +34,7 @@ #' will result in TRUE) #' #' @examples +#' library(data.table) #' x <- data.table(start=c(1L,2L),end=c(3L,4L)) #' is.overlapping(x,c("start","end")) #the interval 1,3 overlaps with the interval 2,4 #' diff --git a/man/CJ.dt.Rd b/man/CJ.dt.Rd index be69235..52ea4fe 100644 --- a/man/CJ.dt.Rd +++ b/man/CJ.dt.Rd @@ -20,6 +20,7 @@ CJ.dt computes successive cartesian join over rows of each table paying no attention to whatever the tables are keyed on. } \examples{ +library(data.table) #' CJ.dt(data.table(c(1,2,2),c(1,1,1)),data.table(c("a","b"),c("c","d"))) #If you want to expand x to unique values of a non-unique columns in y x <- data.table(c(1,2,3),c("a","b","b")) diff --git a/man/intervalaverage.Rd b/man/intervalaverage.Rd index 7b74a33..c158691 100644 --- a/man/intervalaverage.Rd +++ b/man/intervalaverage.Rd @@ -133,6 +133,7 @@ does not affect whether the average value is returned as NA or not--you'll need criteria using this (these) maxgap variables. } \examples{ +library(data.table) x <- data.table(start=seq(1L,by=7L,length=6), end=seq(7L,by=7L,length=6), pm25=c(10,12,8,14,22,18)) diff --git a/man/intervalintersect.Rd b/man/intervalintersect.Rd index fbfd84e..fdde8fc 100644 --- a/man/intervalintersect.Rd +++ b/man/intervalintersect.Rd @@ -72,6 +72,7 @@ Note that the function returns the same result if you switch x and y (with the exception of switched column names in the case of column name conflicts as just discussed) } \examples{ +library(data.table) set.seed(42) y <- data.table(addr_id=c(1,2,2,3,5), ppt_id=c(1,1,1,2,2), diff --git a/man/is.overlapping.Rd b/man/is.overlapping.Rd index f7c09c6..6d522dc 100644 --- a/man/is.overlapping.Rd +++ b/man/is.overlapping.Rd @@ -46,6 +46,7 @@ will join them all--this is unnecessarily slow and memory intensive if the goal is to just test for the existence of one or more overlap. } \examples{ +library(data.table) x <- data.table(start=c(1L,2L),end=c(3L,4L)) is.overlapping(x,c("start","end")) #the interval 1,3 overlaps with the interval 2,4 diff --git a/man/isolateoverlaps.Rd b/man/isolateoverlaps.Rd index 2152ee7..6f1f545 100644 --- a/man/isolateoverlaps.Rd +++ b/man/isolateoverlaps.Rd @@ -50,6 +50,7 @@ x is not copied but rather passed by reference to function internals but the order of this data.tables is restored on function completion or error. } \examples{ +library(data.table) set.seed(23) x2 <- data.table(addr_id=rep(1:4,each=3), exposure_start=rep(c(1L,7L,14L),times=4), diff --git a/tests/testthat.R b/tests/testthat.R index 1820fe0..7fd04b1 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -1,4 +1,5 @@ library(testthat) library(intervalaverage) +library(data.table) test_check("intervalaverage") diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R new file mode 100644 index 0000000..96fc90c --- /dev/null +++ b/tests/testthat/setup.R @@ -0,0 +1 @@ +library(data.table) diff --git a/vignettes/intervalaverage-advanced.Rmd b/vignettes/intervalaverage-advanced.Rmd index 4f93815..a565750 100644 --- a/vignettes/intervalaverage-advanced.Rmd +++ b/vignettes/intervalaverage-advanced.Rmd @@ -20,6 +20,7 @@ knitr::opts_chunk$set( ```{r setup,echo=FALSE,message=FALSE} library(intervalaverage) +library(data.table) set.seed(1) ``` diff --git a/vignettes/intervalaverage-intro.Rmd b/vignettes/intervalaverage-intro.Rmd index 4921576..819f7c2 100644 --- a/vignettes/intervalaverage-intro.Rmd +++ b/vignettes/intervalaverage-intro.Rmd @@ -18,6 +18,7 @@ knitr::opts_chunk$set( ```{r setup,echo=FALSE,message=FALSE} library(intervalaverage) +library(data.table) ``` *Note: This package and vignette makes extensive use of `data.table`. If @@ -61,6 +62,7 @@ We will use two data sets (included in this package) to demonstrate ```{r} library(intervalaverage) +library(data.table) data("no2") data("address_history") setDT(no2) diff --git a/vignettes/intervalaverage-technicaloverview.Rmd b/vignettes/intervalaverage-technicaloverview.Rmd index 79aa65a..c3100c4 100644 --- a/vignettes/intervalaverage-technicaloverview.Rmd +++ b/vignettes/intervalaverage-technicaloverview.Rmd @@ -17,6 +17,7 @@ knitr::opts_chunk$set( ```{r setup,echo=FALSE,message=FALSE} library(intervalaverage) +library(data.table) ``` ## Motivation From afce16c687220483db8ebc2f642df6c699d22abd Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Wed, 19 Aug 2026 14:10:08 -0700 Subject: [PATCH 2/2] spurious --- tests/testthat/setup.R | 1 - 1 file changed, 1 deletion(-) delete mode 100644 tests/testthat/setup.R diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R deleted file mode 100644 index 96fc90c..0000000 --- a/tests/testthat/setup.R +++ /dev/null @@ -1 +0,0 @@ -library(data.table)