, , , . , melt(), . -. variable value, , ( ) issue, check .
library(reshape2)
library(dplyr)
melt(mydf[,1:4], id.vars = "check") %>%
filter(value != "-") %>%
group_by(variable, value) %>%
summarise(total = n(), check = sum(check), percent = check / total * 100)
# variable value total check percent
# (fctr) (chr) (int) (int) (dbl)
#1 issue_1 a 3 2 66.66667
#2 issue_1 p 1 0 0.00000
#3 issue_2 b 2 2 100.00000
#4 issue_2 r 1 0 0.00000
#5 issue_3 c 1 1 100.00000
#6 issue_3 q 1 1 100.00000
DATA
mydf <- structure(list(issue_1 = structure(c(2L, 1L, 1L, 3L, 1L, 1L,
2L, 2L), .Label = c("-", "a", "p"), class = "factor"), issue_2 = structure(c(1L,
2L, 1L, 1L, 1L, 3L, 1L, 2L), .Label = c("-", "b", "r"), class = "factor"),
issue_3 = structure(c(1L, 1L, 2L, 1L, 3L, 1L, 1L, 1L), .Label = c("-",
"c", "q"), class = "factor"), check = c(0L, 1L, 1L, 0L, 1L,
0L, 1L, 1L), cat_1 = c(1L, 0L, 0L, 1L, 0L, 0L, 1L, 1L), cat_2 = c(0L,
1L, 0L, 0L, 0L, 1L, 0L, 1L), cat_3 = c(0L, 0L, 1L, 0L, 1L,
0L, 0L, 0L)), .Names = c("issue_1", "issue_2", "issue_3",
"check", "cat_1", "cat_2", "cat_3"), class = "data.frame", row.names = c(NA,
-8L))