Good day, It's not described anywhere in the help page, but tapply and by functions will, by default, convert factors into numeric values. Perhaps this needs to be documented or the behaviour changed.
> tapply(1:3, 1:3, function(x) factor(LETTERS[x], levels = LETTERS)) 1 2 3 1 2 3 The documentation states "... tapply returns a multi-way array containing the values ..." but doesn't mention anything about converting factors into integers. I'd expect the values to be of the same type. R version 3.4.0 (2017-04-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Debian GNU/Linux 8 (jessie) Matrix products: default BLAS: /dskh/nobackup/biostat/software/R-3.4.0/lib/libRblas.so LAPACK: /dskh/nobackup/biostat/software/R-3.4.0/lib/libRlapack.so -------------------------------------- Dario Strbenac University of Sydney Camperdown NSW 2050 Australia ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel