Skip to content

review simplify=TRUE rules in frollapply() #7317

@jangorecki

Description

@jangorecki

After #7314 our simplify rules got very wide. The PR meant to add handling for adaptive rolling median.

Considering frollapply manual says

In future version we may improve internal \code{simplifylist} function, then \code{simplify=TRUE} may return object of a different type, breaking downstream code. If results are already simplified with \code{simplify=TRUE}, then it can be considered backward compatible.

it is risky to keep current simplify rules and this statement together.

We should either:

  1. change manual that even simplified results may not be considered backward compatible
  2. or make simplify to work for a less cases

If we go with 2. then this issue can be good for agreeing on the scope of simplifylist().

  1. absolute minimum are:
  • coerce int to double when varies within answer results (frollapply simplifylist could be more smart about median results #7313)
    list(NA, 1.5, 2L) -> c(NA, 1.5, 2)
  • coerce fill to answers type
    list(NA, 1L, 2L) -> c(NA_integer_, 1L, 2L)
    list(-9, 1L, 2L) -> c(-9L, 1L, 2L)
  • unlist for atomic vector of matching types
    list(1, 2, 3) -> c(1,2,3)
  • rbindlist of list/df/dt of matching dimension and types
    list(dt(a=1, b=2), dt(a=2, b=3)) - > dt(a=1:2, b=2:3)
  1. nice to have
  • recycle fill to answers length
    list(NA, 1:2) -> list(c(NA,NA), 1:2)
  • match fill names to answers names
    list(NA, c(a=1,b=2)) -> list(c(a=NA,b=NA), c(a=1,b=2))
  • rbindlist(lapply(x, as.list)) of length 2+ vectors
    list(1:2, 2:3) - > dt(1:2, 2:3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions