if (FALSE) {
# to get an array of just the subtotals
subtotalArray(crtabs(~opinion, ds))
# Agree Disagree
# 47 35
# to get the full array with the subtotals but not headings
applyTransforms(crtabs(~opinion, ds), include = c("cube_cells", "subtotals"))
# Strongly Agree Somewhat Agree Agree
# 23 24 47
# Neither Agree nor Disagree Strongly Disagree Disagree
# 18 19 35
# Somewhat Disagree
# 16
# to get the full array with the headings but not subtotals
applyTransforms(crtabs(~opinion, ds), include = c("cube_cells", "headings"))
# All opinions Strongly Agree Somewhat Agree
# NA 23 24
# Neither Agree nor Disagree Strongly Disagree Somewhat Disagree
# 18 19 16
}
Run the code above in your browser using DataLab