markleeds at verizon.net
2008-Jul-02 02:41 UTC
[R] is there an equivalent of prop.table but for counts
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)
Jorge Ivan Velez
2008-Jul-02 02:50 UTC
[R] is there an equivalent of prop.table but for counts
Dear Mark, Is this what you want? print(margintable,dim=c(8,4)) HTH, Jorge On Tue, Jul 1, 2008 at 10:41 PM, <markleeds@verizon.net> wrote:> 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@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. >[[alternative HTML version deleted]]
Seemingly Similar Threads
- converting a table to a dataframe or a matrix
- ggplot incorrect legend
- using barchart in lattice package and conditioning
- Fast update of a lot of records in a database?
- [PATCH] drm/nouveau: Replace the iturbt_709 prop with the standarad COLOR_ENCODNIG prop