Search notes:

R function: addmargins

#
#     See also -> margin.table
#
m <- matrix (
       c(    4, 1, 3,
             2, 1, 2,
             1, 5, 2,
             4, 3, 1),
       ncol  = 3,
       byrow = TRUE
)

m
#      [,1] [,2] [,3]
# [1,]    4    1    3
# [2,]    2    1    2
# [3,]    1    5    2
# [4,]    4    3    1

addmargins(m)
#      [,1] [,2] [,3] [,4]
# [1,]    4    1    3    8
# [2,]    2    1    2    5
# [3,]    1    5    2    8
# [4,]    4    3    1    8
# [5,]   11   10    8   29
Github repository about-r, path: /functions/addmargins.R

See also

Index to (some) R functions

Index