Skip to content

frollapply can produce output longer than the input when the window-length is also longer than the input #7646

@hadley-johnson

Description

@hadley-johnson

Is it expected that the new version of frollapply() and frollsum() for data.table version 1.18 behave differently when the window length is larger than the data object? Or is this a bug?

The difference noted below does not happen using data.table version 1.17.

Using frollsum() the output always has the same length as the input object:

frollsum(c(1,2,3,4,5),n=5)
[1] NA NA NA NA 15
frollsum(c(1,2,3,4,5),n=6)
[1] NA NA NA NA NA
frollsum(c(1,2,3,4,5),n=7)
[1] NA NA NA NA NA

But using frollapply() the output can be longer than the input object:

frollapply(c(1,2,3,4,5),N=5,FUN=sum)
[1] NA NA NA NA  15
frollapply(c(1,2,3,4,5),N=6,FUN=sum)
[1] NA NA NA NA NA
frollapply(c(1,2,3,4,5),N=7,FUN=sum)
[1] NA NA NA NA NA NA

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions