On Mon, 2007-10-08 at 16:18 +0200, Alessandra Marmo wrote:
> Hello
> I need to print table width "colum sum" like
> X    V1    V2    TOT
> A    2    3            5
> B    1    6            7
> C    4    6           10
> 
> how i can do it by table function?
> 
> Thanks
> 
> Alessandra

Presuming that your object above is a data frame, you can add a new
column using cbind():

> tab
  X V1 V2
1 A  2  3
2 B  1  6
3 C  4  6


> cbind(tab, TOT = tab$V1 + tab$V2)
  X V1 V2 TOT
1 A  2  3   5
2 B  1  6   7
3 C  4  6  10

See ?cbind.

For actual R tables, you can use ?addmargins

HTH,

Marc Schwartz

______________________________________________
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