Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
24 changes: 23 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
5 changes: 4 additions & 1 deletion R/intervalaverage_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ 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"))
#' y <- data.table(id=c(1,2,2,1,3),value=c(2,4,1,7,3))
#' 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(...)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions R/intervalintersect.r
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions R/isoverlapping.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
#'
Expand Down
1 change: 1 addition & 0 deletions man/CJ.dt.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/intervalaverage.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/intervalintersect.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/is.overlapping.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/isolateoverlaps.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
library(testthat)
library(intervalaverage)
library(data.table)

test_check("intervalaverage")
1 change: 1 addition & 0 deletions vignettes/intervalaverage-advanced.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ knitr::opts_chunk$set(

```{r setup,echo=FALSE,message=FALSE}
library(intervalaverage)
library(data.table)
set.seed(1)
```

Expand Down
2 changes: 2 additions & 0 deletions vignettes/intervalaverage-intro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions vignettes/intervalaverage-technicaloverview.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ knitr::opts_chunk$set(

```{r setup,echo=FALSE,message=FALSE}
library(intervalaverage)
library(data.table)
```

## Motivation
Expand Down