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.

Reply via email to