Skip to content

Commit 8eb449d

Browse files
committed
Merge branch 'frolladapt2025' into frollapply-nneg
2 parents ff55a0b + 50061db commit 8eb449d

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

NEWS.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -225,36 +225,36 @@
225225

226226
18. New `frolladapt` helper function has been added to aid in preparation of adaptive length of rolling window width when dealing with _irregularly spaced ordered data_. This lets the user to apply a rolling function over a period without having to deal with gaps in a data where some periods might be missing, [#3241](https://github.com/Rdatatable/data.table/issues/3241). Thanks to @jangorecki for implementation.
227227
```r
228-
idx = as.Date("2022-10-23") + c(0,1,4,5,6,7,9,10,14)
228+
idx = as.Date("2025-09-08") + c(0,1,4,5,6,7,9,10,14)
229229
dt = data.table(index=idx, value=seq_along(idx))
230230
dt
231231
# index value
232232
# <Date> <int>
233-
#1: 2022-10-23 1
234-
#2: 2022-10-24 2
235-
#3: 2022-10-27 3
236-
#4: 2022-10-28 4
237-
#5: 2022-10-29 5
238-
#6: 2022-10-30 6
239-
#7: 2022-11-01 7
240-
#8: 2022-11-02 8
241-
#9: 2022-11-06 9
233+
#1: 2025-09-08 1
234+
#2: 2025-09-09 2
235+
#3: 2025-09-12 3
236+
#4: 2025-09-13 4
237+
#5: 2025-09-14 5
238+
#6: 2025-09-15 6
239+
#7: 2025-09-17 7
240+
#8: 2025-09-18 8
241+
#9: 2025-09-22 9
242242
dt[, c("rollmean3","rollmean3days") := list(
243243
frollmean(value, 3),
244244
frollmean(value, frolladapt(index, 3), adaptive=TRUE)
245245
)]
246246
dt
247247
# index value rollmean3 rollmean3days
248248
# <Date> <int> <num> <num>
249-
#1: 2022-10-23 1 NA NA
250-
#2: 2022-10-24 2 NA NA
251-
#3: 2022-10-27 3 2 3.0
252-
#4: 2022-10-28 4 3 3.5
253-
#5: 2022-10-29 5 4 4.0
254-
#6: 2022-10-30 6 5 5.0
255-
#7: 2022-11-01 7 6 6.5
256-
#8: 2022-11-02 8 7 7.5
257-
#9: 2022-11-06 9 8 9.0
249+
#1: 2025-09-08 1 NA NA
250+
#2: 2025-09-09 2 NA NA
251+
#3: 2025-09-12 3 2 3.0
252+
#4: 2025-09-13 4 3 3.5
253+
#5: 2025-09-14 5 4 4.0
254+
#6: 2025-09-15 6 5 5.0
255+
#7: 2025-09-17 7 6 6.5
256+
#8: 2025-09-18 8 7 7.5
257+
#9: 2025-09-22 9 8 9.0
258258
```
259259

260260
### BUG FIXES

R/froll.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ frolladapt = function(x, n, align="right", partial=FALSE, give.names=FALSE) {
135135
if (!identical(align, "right"))
136136
stopf("'align' other than 'right' has not yet been implemented")
137137
if (!isTRUEorFALSE(partial))
138-
stopf("'partial' must be TRUE or FALSE")
138+
stopf("'%s' must be TRUE or FALSE", "partial")
139139
if (!isTRUEorFALSE(give.names))
140-
stopf("'give.names' must be TRUE or FALSE")
140+
stopf("'%s' must be TRUE or FALSE", "give.names")
141141

142142
if (length(n) == 1L) {
143143
ans = .Call(Cfrolladapt, x, n, partial)

src/frollR.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ SEXP frolladapt(SEXP xobj, SEXP kobj, SEXP partial) {
216216
int n = INTEGER(kobj)[0];
217217
if (n < 1L)
218218
error(_("'n' must be positive integer values (>= 1)"));
219-
int *x = INTEGER(xobj);
219+
int *x = INTEGER_RO(xobj);
220220
int64_t len = XLENGTH(xobj); // can be 0
221221

222222
if (len && x[0] == NA_INTEGER)
@@ -264,4 +264,4 @@ SEXP frolladapt(SEXP xobj, SEXP kobj, SEXP partial) {
264264
}
265265
UNPROTECT(1);
266266
return ans;
267-
}
267+
}

0 commit comments

Comments
 (0)