[R] is there an equivalent of prop.table but for counts

From: <markleeds_at_verizon.net>
Date: Tue, 01 Jul 2008 21:41:39 -0500 (CDT)


I have a simple table below called temptable and i want to obtain the same structure that prop.table creates except get the counts rather than the proportions. margin.table seems to create one table with columns and rows whereas I am looking for the three table type structure that prop.table gives. Thanks.

temptable<-structure(c(0L, 2L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L,

0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 1L, 1L, 1L, 0L, 0L, 2L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 1L, 0L,
0L, 2L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L,
1L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L,
0L, 0L, 3L), .Dim = c(8L, 4L, 3L), .Dimnames = structure(list(
     c("(-1,-0.75]", "(-0.75,-0.5]", "(-0.5,-0.25]", "(-0.25,0]",

"(0,0.25]", "(0.25,0.5]", "(0.5,0.75]", "(0.75,1]"),
c("(-Inf,-0.001]",
"(-0.001,0]", "(0,0.001]", "(0.001, Inf]"), c("Neutral",
"Negative", "Positive")), .Names = c("", "", "")), class = "table")

proptable <- prop.table(temptable,margin=c(1,2)) print(proptable)

margintable <- margin.table(temptable,margin=c(1,2)) print(margintable)



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 02 Jul 2008 - 02:44:51 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 02 Jul 2008 - 03:31:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive