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]]
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.
?addmargins Peter Alspach> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of Georg Ehret > Sent: Thursday, 25 October 2007 9:19 a.m. > To: r-help > Subject: [R] adding total row/column to table-command > > 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. >___________________________________________________________________ The contents of this e-mail are privileged and/or confidential to the named recipient and are not to be used by any other person and/or organisation. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail.