Skip to content
Prev 56498 / 63421 Next

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

Peter, we are arguing at cross purposes.? My point was that if I have specified 
options(stringsAsFactors=FALSE) that is a statement to R to NOT DO THIS.?? Your argument 
in return is that "yes, Therneau said that, but in this case he almost certainly doesn't 
really mean it, so ignore him".? Now the first part of your sentence may quite possibly be 
true.? I still don't like the second.

Of course, the best would be consistency from the start.? If I want a data frame form of 
table(a, b), what some packages call list mode, have the class of a, b in the result match 
the class of a,b at the start: character to character, factor to factor, numeric to 
numeric, etc.? The fact that all of them ended up as character in the intermediate 
dimnames takes much of the wind out my argument above: when converting a table to a 
dataframe the best R can do is guess what the original class was. ? Factor might indeed be 
the best guess, lacking a data.frame=TRUE argument for table().

Here, though I hate to say it, is an argument for your side: data.frame(table( rep(1:10, 
length=15)))
"10" should be after "9".

Terry T.
On 3/15/19 8:31 AM, peter dalgaard wrote: