Search notes:

R function: margin.table

#
#     See also -> addmargins
#

m <- matrix (
       c(    4, 1, 3,
             2, 1, 2,
             1, 5, 2,
             4, 3, 1),
       ncol  = 3,
       byrow = TRUE
)

margin.table(m)
# [1] 29
sum(m)
# [1] 29

margin.table(m, 1)
# [1] 8 5 8 8
apply(m, 1, sum)
# [1] 8 5 8 8

margin.table(m, 2)
# [1] 11 10  8
apply(m, 2, sum)
# [1] 11 10  8
Github repository about-r, path: /functions/margin.table.R

See also

Index to (some) R functions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758200823, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/functions/margin_table(65): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78