-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8df55b4
commit bf6c236
Showing
2 changed files
with
74 additions
and
77 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#' Extract the quantitative responses from the feedback survey. | ||
#' | ||
#' @name extract_feedback | ||
#' @rdname extract_feedback | ||
#' @param data The feedback data. | ||
#' | ||
#' @return A tibble. | ||
#' | ||
NULL | ||
|
||
#' @describeIn extract_feedback Extract and tidy up the quantitative responses | ||
#' from the feedback survey data. | ||
#' @export | ||
extract_feedback_quantitative <- function(data) { | ||
data %>% | ||
dplyr::filter(stringr::str_detect(question, "Please complete these .*")) %>% | ||
dplyr::mutate( | ||
statement = stringr::str_remove(question, "Please .* course. ") %>% | ||
stringr::str_remove_all("\\[|\\]") | ||
) %>% | ||
dplyr::select(tidyselect::all_of(c( | ||
"course_version", "date", "statement", "response" | ||
))) |> | ||
dplyr::count(course_version, date, statement, response) |> | ||
dplyr::arrange(course_version, date) | ||
} | ||
|
||
#' @describeIn extract_feedback Extract and tidy up the overall comments | ||
#' from the feedback survey data. | ||
#' @export | ||
extract_feedback_overall <- function(data) { | ||
data %>% | ||
dplyr::filter(stringr::str_detect( | ||
question, | ||
".*any other (feedback|comments) .*" | ||
)) %>% | ||
dplyr::rename(overall_comments = response) %>% | ||
dplyr::select(-question, -id, -day) %>% | ||
dplyr::filter(stringr::str_detect( | ||
overall_comments, | ||
"^No$", | ||
negate = TRUE | ||
)) %>% | ||
dplyr::arrange(course_version, date) | ||
} | ||
|
||
#' @describeIn extract_feedback Extract and tidy up the session specific | ||
#' comments from the feedback survey data. | ||
#' @export | ||
extract_feedback_sessions <- function(data) { | ||
data %>% | ||
dplyr::filter(stringr::str_detect(question, | ||
"Please complete these .*|any other (feedback|comments) .*", | ||
negate = TRUE | ||
)) %>% | ||
dplyr::mutate(question = question %>% | ||
stringr::str_remove_all('What|session|\\"|\\?') %>% | ||
stringr::str_trim()) %>% | ||
tidyr::separate( | ||
col = question, | ||
into = c("worked_or_improve", "session"), | ||
sep = "for the" | ||
) %>% | ||
dplyr::mutate( | ||
worked_or_improve = snakecase::to_snake_case(worked_or_improve), | ||
session = stringr::str_trim(session) | ||
) %>% | ||
tidyr::pivot_wider( | ||
names_from = worked_or_improve, | ||
values_from = response | ||
) %>% | ||
dplyr::select(-id) %>% | ||
dplyr::arrange(course_version, date, day, session) | ||
} |
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