Skip to content

Instantly share code, notes, and snippets.

@ChrisBeeley
Created April 18, 2019 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisBeeley/18d7984709cc839cde8aa4320954bf69 to your computer and use it in GitHub Desktop.
Save ChrisBeeley/18d7984709cc839cde8aa4320954bf69 to your computer and use it in GitHub Desktop.
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