sgaure / lfe

Source code repository for the R package lfe on CRAN.
53 stars 18 forks source link

return value of `demeanlist` inconsistent for argument `na.rm` #50

Open tappek opened 3 years ago

tappek commented 3 years ago

The return value of demeanlist for matrix input is inconsistent when argument na.rm is flipped, see the example below.

For matrix inputs for the first argument, the return value is specified to be a matrix in the documentation (maybe other allowed inputs are treated inconsistently for na.rm (I did not check)).

m <- matrix(1:10, ncol = 2)
fl <- list(factor(c(1,1,2,2,2)))

res1 <- lfe::demeanlist(m, fl = fl, na.rm = FALSE)
res2 <- lfe::demeanlist(m, fl = fl, na.rm = TRUE)

class(res1) # c("matrix", "array")
class(res2) # c("list")

res22 <- res2[[1]]
identical(res1, res22) # TRUE