Suppose I have data in an R table which looks like this:
Id  Name Price sales Profit Month Category Mode
1   A     2     5     8       1     X       K
1   A     2     6     9       2     X       K
1   A     2     5     8       3     X       K
1   B     2     4     6       1     Y       L
1   B     2     3     4       2     Y       L
1   B     2     5     7       3     Y       L
2   C     2     5    11       1     X       M
2   C     2     5    11       2     X       L
2   C     2     5    11       3     X       K
2   D     2     8    10       1     Y       M
2   D     2     8    10       2     Y       K
2   D     2     5    7        3     Y       K
3   E     2     5    9        1     Y       M
3   E     2     5    9        2     Y       L
3   E     2     5    9        3     Y       M
3   F     2     4    7        1     Z       M
3   F     2     5    8        2     Z       L
3   F     2     5    8        3     Z       M
If I use the table function on this data like:
table(df$Category, df$Mode)
It will show me under each mode which category has how many observations. It's like counting the number of items in each category under each mode.
But what if I want the table to show under each Category which Mode earned how much Profit (sum or mean) and not the total count?
Is there any way to do this with the table function or another function in R?
 
     
     
     
    