data(efc)
# flat table with counts
flat_table(efc, e42dep, c172code, e16sex)
# flat table with proportions
flat_table(efc, e42dep, c172code, e16sex, margin = "row")
# flat table from grouped data frame. You need to select
# the grouping variables and at least two more variables for
# cross tabulation.
library(dplyr)
efc %>%
group_by(e16sex) %>%
select(e16sex, c172code, e42dep) %>%
flat_table()
efc %>%
group_by(e16sex, e42dep) %>%
select(e16sex, e42dep, c172code, n4pstu) %>%
flat_table()
# now it gets weird...
efc %>%
group_by(e16sex, e42dep) %>%
select(e16sex, e42dep, c172code, n4pstu, c161sex) %>%
flat_table()
Run the code above in your browser using DataLab