0

I am analyzing data from a "Select all that apply" question and want to create a summary table of each response. When exporting data, my df looks like this:

q1_option1 <- c("1", "0", "1", "0")
q1_option2 <- c("0", "0", "1", "1")
q1_option3 <- c("1", "1", "1", "1")
df <- data.frame(option1, option2, option3)

And I would like to create summary tables like:


               yes (%)     no (%)
q1_option1    2 (50%)     2 (50%)
q1_option2    2 (50%)     2 (50%)
q1_option3    4 (100%)    0

I feel like this should be a simple solution but I've spent all day trying to find an answer.

epi_123
  • 23
  • 5
  • Welcome to [SO](https://stackoverflow.com/) @epi_123 can you please share the codes/approach you followed – Isa Dec 10 '21 at 04:46
  • There are many ways, try to search existing posts, for ecample: `prop.table(table(stack(df)), 2) * 100` – zx8754 Dec 10 '21 at 04:49

0 Answers0