Skip to content

Commit

Permalink
Exports and improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
NicChr committed May 23, 2024
1 parent 0408323 commit 4215f24
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ S3method(base::unique,year_month)
S3method(base::unique,year_quarter)
S3method(base::xtfrm,time_interval)
S3method(cheapr::is_na,Interval)
S3method(collapse::GRP,Interval)
S3method(collapse::GRP,NULL)
S3method(collapse::GRP,time_interval)
S3method(dplyr::dplyr_col_modify,data.table)
S3method(dplyr::dplyr_reconstruct,episodes_tbl_df)
S3method(dplyr::dplyr_reconstruct,time_tbl_df)
Expand Down
5 changes: 4 additions & 1 deletion R/GRP_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ df_to_GRP <- function(data, .cols = character(0),
# }
# out
# }
#' @exportS3Method collapse::GRP
GRP.Interval <- function(X, ...){
x <- X
X <- interval_separate(x)
Expand All @@ -596,7 +597,8 @@ GRP.Interval <- function(X, ...){
}
out
}
GRP.time_interval<- function(X, ...){
#' @exportS3Method collapse::GRP
GRP.time_interval <- function(X, ...){
x <- X
X <- as.list(x)
out <- collapse::GRP(X, ...)
Expand All @@ -605,6 +607,7 @@ GRP.time_interval<- function(X, ...){
}
out
}
#' @exportS3Method collapse::GRP
GRP.NULL <- function(X, ...){
NULL
}
Expand Down
6 changes: 4 additions & 2 deletions R/time_seq_fill.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ time_seq_fill <- function(x, time_by = NULL,
na_count <- cpp_consecutive_na_id(x, TRUE)

# These should all be equal to 1
seq_diff <- (elapsed - roll_lag(na_count, fill = 0L))
is_regular <- all(abs(seq_diff - 1) < sqrt(.Machine$double.eps), na.rm = TRUE)
na_count <- cheapr::lag_(na_count, fill = 0L, set = TRUE)
elapsed <- cheapr::set_subtract(elapsed, na_count)
is_regular <- all(cheapr::set_abs(cheapr::set_subtract(elapsed, 1)) <
sqrt(.Machine$double.eps), na.rm = TRUE)
if (!is_regular){
stop("x must be a regular sequence with no duplicates or implicit gaps in time.")
}
Expand Down

0 comments on commit 4215f24

Please sign in to comment.