[rkward-devel] (no subject)
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Sun Mar 6 12:31:09 UTC 2011
Hi,
On Friday 04 March 2011, Andrés Necochea wrote:
> Hi. This is a suggestion for present a bidimensional contingency table
> in rkward using an R function.
thanks for sharing your work with us. This would certainly be a useful
addition to the crosstabulation plugin. However, I'm not quite sure, this is
the right way to do it. I have two main concerns. The first is that this mixes
"calculating" and "printing" (i.e. formatting of output) into single function.
The second is that I'm always a bit reluctant to add too much functionality
into RKWard itself, which could reasonably be useful in a different context,
too (in this case, perhaps this could be placed in the R2HTML package).
Generally, we try to offer a GUI to R functions, not R functions.
Well, let's ignore the second concern for now. Perhaps my first concern could
be addressed by re-structuring a bit: What if we look at the desired output as
three-dimensional table, instead: frequency, total%, row%, and col% would
simply be treated as sub-divisions of each level of the "independent"
("Opinion", in your example). The two trailing columns for Frequency and
Percentage would be turned into a single column "Sum", which has the same sub-
divisions as all other cells (sum of row% and col% would always be 100% ,
here, of course).
This would allow to split the problem into two parts: First, producing a three
dimensional table with four "layers", second, turning that table into HTML.
The first part would be something like:
y <- c (x, prop.table (x), x / c(margin.table (x, 1)), x / margin.table (x,
2))
dim (y) <- c (dim (x), 4)
dimnames (y) <- c (dimnames (x), list (c ("Frequency", "% of total", "% of
row", "% of column")))
y <- addmargins (y, seq_along (dim (x))
Admittedly this does not look terribly elegant (I wish there was something
like cbind() for tables), but now everything is in one table. Now the
remainder would be to write a generic function that will print a three-
dimensional table. The good thing about this is that a) it could be extended
to include additional statistics in a straight-forward way, and b) the
printing function might be useful in other use-cases, too.
What do you think of this idea?
Regards
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20110306/b9622ed7/attachment.sig>
More information about the Rkward-devel
mailing list