Sebastian Martin Krantz
2022-Oct-28 17:41 UTC
[Rd] pmin() and pmax() should process a single list of vectors, rather than returning it
Dear R Core, The {kit} package has a nice set of parallel statistical functions complimenting base R's pmin() and pmax(): psum(), pprod(), pmean(), etc.. These can be called on a set of vectors like pmin() and pmax() e.g. with(mtcars, psum(mpg, carb, wt)) or on a single list of vectors e.g. psum(mtcars). In contrast, pmin() and pmax() only allow the former. Calling pmax(mtcars) oddly returns mtcars as is, without giving any error or warning. I think this behavior should be changed to come in line with the kit versions. kit::psum is defined as: psum <- function(..., na.rm=FALSE) .Call(CpsumR, na.rm, if (...length() =1L && is.list(..1)) ..1 else list(...)) The first line of pmin() and pmax() is elts <- list(...). I propose changing that first line to: elts <- if (...length() == 1L && is.list(..1)) unclass(..1) else list(...). This will provide convenient functionality (do.call(pmax, mtcars) is inconvenient), and guard against the (odd) behavior of simply returning a list passed to these functions. Best regards, Sebastian Krantz [[alternative HTML version deleted]]