Skip to content

Commit 19bb9c7

Browse files
committed
code blocks for news file
1 parent e07023a commit 19bb9c7

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

NEWS.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -224,38 +224,38 @@
224224
```
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.
227-
```r
228-
idx = as.Date("2025-09-08") + c(0,1,4,5,6,7,9,10,14)
229-
dt = data.table(index=idx, value=seq_along(idx))
230-
dt
231-
# index value
232-
# <Date> <int>
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
242-
dt[, c("rollmean3","rollmean3days") := list(
243-
frollmean(value, 3),
244-
frollmean(value, frolladapt(index, 3), adaptive=TRUE)
245-
)]
246-
dt
247-
# index value rollmean3 rollmean3days
248-
# <Date> <int> <num> <num>
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
258-
```
227+
```r
228+
idx = as.Date("2025-09-08") + c(0,1,4,5,6,7,9,10,14)
229+
dt = data.table(index=idx, value=seq_along(idx))
230+
dt
231+
# index value
232+
# <Date> <int>
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
242+
dt[, c("rollmean3","rollmean3days") := list(
243+
frollmean(value, 3),
244+
frollmean(value, frolladapt(index, 3), adaptive=TRUE)
245+
)]
246+
dt
247+
# index value rollmean3 rollmean3days
248+
# <Date> <int> <num> <num>
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
258+
```
259259

260260
### BUG FIXES
261261

0 commit comments

Comments
 (0)