Here is a toy data.frame:
sex = c(rep("M", 4), rep("F", 4))
bg = c(rep("W",2),rep("NW",2),rep("W",2),rep("NW",2))
income = c(156,185,105,115,95,78,67,74)
(data = data.frame(income, sex, bg))
income sex bg
1 156 M W
2 185 M W
3 105 M NW
4 115 M NW
5 95 F W
6 78 F W
7 67 F NW
8 74 F NW
I am looking for a way to turn this object into a cross-table with, for example, the mean in every cell: