addmargins Function in R (2 Examples) | Append Arbitrary Margins to Data | Mean to Contingency Table

preview_player
Показать описание
R code of this video:

"B", "B", "C"),
x2 = letters[1:2])
data # Print example data frame

my_tab <- table(data) # Create contingency table
my_tab # Print contingency table

tab_sum <- addmargins(my_tab, FUN = sum) # Apply addmargins function
tab_sum # Table with sum margins

tab_mean <- addmargins(my_tab, FUN = mean) # Apply addmargins function
tab_mean # Table with mean margins

Follow me on Social Media:

Рекомендации по теме
Комментарии
Автор

Hi,
What is the benefit of table over data frame?

arash