[Rd] as.data.frame.table() does not recognize default.stringsAsFactors()

Therneau, Terry M., Ph.D. therne@u @end|ng |rom m@yo@edu
Fri Mar 15 13:13:43 CET 2019


I have to disagree with both Peter and Martin on this.

The underneath issue is that the automatic conversion of characters to factors by the 
data.frame functions was the single most egregious design blunder in the Statistical 
Models in S book, and we are still living with it.  The stringsAsFactors option was a 
compromise to let users opt out of that mistake (one I had to fight hard for).    In that 
light I read Peter's defense as "but in this case we really DO know better than the user, 
and won't let them opt out", and Martin's as "they shouldn't have been able to opt out in 
the first place, so weaken it at every opportunity".

I generally agree that global options should be minimal.  But if one exists, let's be 
consistent and listen to it.

(Footnote: In the Mayo Biostat group, stringsAsFactors=FALSE is the recommended global 
option for all users.  It's a pure cost/productivity thing.  We work on thousands of data 
sets in a year, and the errors and misunderstandings that silent conversions generate far 
outweigh any benefits. )

Terry T.


On 3/15/19 6:00 AM, r-devel-request using r-project.org wrote:
>      > I have no recollection of the original rationale for as.data.frame.table, but I actually think it is fine as it is:
>      > The classifying_factors_  of a crosstable should be factors unless very specifically directed otherwise and that should not depend on the setting of an option that controls the conversion of character data.
>
>      > For as.data.frame.matrix, in contrast, it is the_content_  of the matrix that is being converted, and it seems much more reasonable to follow the same path as for other character data.
>
>      > -pd
>
> I very strongly agree that as.data.frame.table() should not be
> changed to follow a global option.
>
> To the contrary: I've repeatedly mentioned that in my view it
> has been a design mistake to allow data.frame() and as.data.frame() be influenced
> by a global option
>   [and we should've tried harder to keep things purely functional
>     (R remaining as closely as possible a "functional language"),
>    e.g. by providing wrapper functions the same way we have such
>    wrappers for versions of read.table() with different defaults
>    for some of the arguments
>   ]


	[[alternative HTML version deleted]]



More information about the R-devel mailing list