This is example data which may be used:
library(readxl)
data.source <- read_excel("I:/Departments/Insight Department/7 R&D/R Training/Multi response data.xlsx")
data.source
#> # A tibble: 12 x 6
#> URN Blank Oil MOT Rep Other
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 aaa 0 0 0 0 1
#> 2 bbb 0 0 0 0 1
#> 3 ccc 0 1 1 0 0
#> 4 ddd 0 1 1 1 0
#> 5 eee 0 0 1 0 0
#> 6 fff 0 0 0 1 0
#> 7 ggg 0 0 0 0 1
#> 8 hhh 0 0 0 0 1
#> 9 iii 0 1 0 1 0
#> 10 jjj 0 0 0 0 1
#> 11 kkk 1 0 0 0 0
#> 12 lll 0 0 0 0 1
Created on 2019-10-11 by the reprex package (v0.3.0)
I need to create one variable (set) containing all 0-1 variables above. What I have done so far, was creating some data frames manually:
categories <- data.frame(Freq=colSums(data.source[2:6]),
Pct.of.Resp=(colSums(data.source[2:6])/sum(data.source[2:6]))*100,
Pct.ofCases=(colSums(data.source[2:6])/nrow(data.source[2:6]))*100)
no.blank.categories <- data.frame(Freq=colSums(data.source[3:6]),
Pct.of.Resp=(colSums(data.source[3:6])/sum(data.source[3:6]))*100,
Pct.ofCases=(colSums(data.source[3:6])/nrow(data.source[3:6]))*100)
What do you think?