Created
April 18, 2019 15:47
-
-
Save ChrisBeeley/18d7984709cc839cde8aa4320954bf69 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fixedData[, missnum > 2] %>% | |
gather(L1, value) %>% | |
filter(!is.na(value)) %>% | |
left_join(select(questionFrame, code, value), by = c("L1" = "code")) %>% | |
select(-L1) %>% | |
group_by(value.y) %>% | |
count(value.x) %>% | |
mutate(prop = prop.table(n) * 100) %>% | |
select(-n) %>% | |
mutate(value.x = factor(value.x, levels = 1:5)) %>% | |
spread(value.x, prop, drop = FALSE) %>% | |
ungroup() %>% | |
setNames(c("Question", rev(c("Excellent", "Good", "Fair", "Poor", "Very poor")))) %>% | |
mutate_if(is.numeric, funs(replace(., is.na(.), 0))) %>% | |
mutate(Score = (Excellent * 5 + Good * 4 + Fair * 3 + Poor * 2 + `Very poor` * 1) / 5) %>% | |
datatable(rownames = FALSE) %>% | |
formatRound(TRUE, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment