[Rd] data frame method for as.table()

Ernest Adrogué eac at openmailbox.org
Mon May 23 20:56:50 CEST 2016


Hi,

2016-05-23, 12:50 (-0500); Marc Schwartz escriu:
> Hi,
> 
> I have not tried an exhaustive set of examples, but I believe that ?xtabs
> will get you most of the way there, with the exception of NA handling,
> which would require either nuanced use of ?addNA or preprocessing factors
> in the input data frame to possibly add NA as a factor level where needed.
> 
> BTW, from ?as.data.frame.table, see the reference there to xtabs() at the
> end:
> 
> "The as.data.frame method for objects inheriting from class "table" can be
> used to convert the array-based representation of a contingency table to a
> data frame containing the classifying factors and the corresponding
> entries (the latter as component named by responseName). This is the
> inverse of xtabs."
> 
> 
> For example, from ?xtabs, using the ?UCBAdmissions dataset, which is a 3
> dimension table:
>
[...]

Thanks... I didn't know about xtabs and addNA.  I'll look into it, but at
first sight it seems that the functionality is pretty much already covered
by some combination of these two,.

Regards.



More information about the R-devel mailing list