Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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