[R] adding total row/column to table-command

Benilton Carvalho bcarvalh at jhsph.edu
Wed Oct 24 22:26:51 CEST 2007


yes, addmargins()

x = matrix(1:16, nc=4)
addmargins(x)

b

On Oct 24, 2007, at 4:19 PM, Georg Ehret wrote:

> Dear R,
>    I am often adding a total rows or column (sum over all rows or  
> columns)
> when using table(data$1,data$2)... I do this now by adding the rows/ 
> columns
> and rbind() or cbind()... But there must be a more efficient  
> way.... Could
> someone please give me a hint?
>
> Thank you!
> With my best regards, Georg.
> *******************
> Georg Ehret
> Johns Hopkins
> Baltimore
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.



More information about the R-help mailing list