From dstr7320 at uni.sydney.edu.au  Fri Jun 16 08:00:20 2017
From: dstr7320 at uni.sydney.edu.au (Dario Strbenac)
Date: Fri, 16 Jun 2017 06:00:20 +0000
Subject: [Rd] Simplify and By Convert Factors To Numeric Values
Message-ID: <DM5PR01MB32592033EEE2E8C8CC012DABCDC10@DM5PR01MB3259.prod.exchangelabs.com>

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



[Rd] Simplify and By Convert Factors To Numeric Values
Dario Strbenac