Skip to content

Instantly share code, notes, and snippets.

@ctesta01
Last active December 8, 2016 21:03
Show Gist options
  • Save ctesta01/c1a7b9087a774085de17688dc730a252 to your computer and use it in GitHub Desktop.
Save ctesta01/c1a7b9087a774085de17688dc730a252 to your computer and use it in GitHub Desktop.
splitting fletcher comments
library(QualtricsTools)
source("Q:/Student Work/Emma's Student Work/Report Generation/Comment Coding/comment-coding.R")
get_setup(
qsf_path = "Q:/Student Work/Emma's Student Work/Report Generation/Comment Coding/examples/fletcher/Fletcher_Continuing_and_Exiting_Student_Survey_2016.qsf",
csv_path = "Q:/Student Work/Emma's Student Work/Report Generation/Comment Coding/examples/fletcher/Fletcher_Continuing_and_Exiting_Student_Survey_2016.csv",
headerrows=2)
# make sure to skip question 1 (meta data)
questions[[5]][['verbatimSkip']] <- TRUE
blocks <- questions_into_blocks(questions, blocks)
# create merged response column
responses <- create_merged_response_column(c("Q2", "Q5"), "cont-exit-prog", blocks, responses)
# load fletcher coded comments
fletcher_comments_directory <- "Q:/Student Work/Emma's Student Work/Fletcher Continue Exit 2016/Christian's Comment Coding/Christians Renamed Coded Comments/Overall"
coded_sheets <- directory_get_coded_comment_sheets(fletcher_comments_directory)
# split and table coded comments according to the "cont-exit-prog" column in the responses
split_comment_tables <- format_and_split_comment_sheets(coded_sheets, responses, "cont-exit-prog")
# split the survey
split_blocks <- split_respondents("cont-exit-prog", responses, survey, blocks, questions, headerrows=2)
# insert the split comments into the survey
split_blocks <- insert_split_survey_comments(split_blocks, split_comment_tables, "cont-exit-prog", original_first_rows)
### Writing Output Files
# specify output directory
output_dir <- "Q:/Student Work/Emma's Student Work/Report Generation/Comment Coding/examples/fletcher/"
# save flow for text_appendices_table-ing
flow = flow_from_survey(survey)
# Record the names for each split survey
# To figure out the names that you should use (in general), I suggest looking at the output
# > sapply(split_blocks, function(x) x$split_group)
# [1] "I will continue on as a student at Fletcher for the next academic year. + LLM"
# [2] "I will continue on as a student at Fletcher for the next academic year. + MA"
# [3] "I will continue on as a student at Fletcher for the next academic year. + MAHA"
# [4] "I will continue on as a student at Fletcher for the next academic year. + MALD"
# [5] "I will continue on as a student at Fletcher for the next academic year. + MIB"
# [6] "I will continue on as a student at Fletcher for the next academic year. + PhD"
# [7] "I will graduate from Fletcher in May or August 2016. + LLM"
# [8] "I will graduate from Fletcher in May or August 2016. + MA"
# [9] "I will graduate from Fletcher in May or August 2016. + MALD"
# [10] "I will graduate from Fletcher in May or August 2016. + MIB"
# [11] "I will graduate from Fletcher in May or August 2016. + PhD"
split_names <- list()
split_names[[1]] = "Cont LLM.docx"
split_names[[2]] = "Cont MA.docx"
split_names[[3]] = "Cont MAHA.docx"
split_names[[4]] = "Cont MALD.docx"
split_names[[5]] = "Cont MIB.docx"
split_names[[6]] = "Cont PhD.docx"
split_names[[7]] = "Exiting LLM.docx"
split_names[[8]] = "Exiting MA.docx"
split_names[[9]] = "Exiting MALD.docx"
split_names[[10]] = "Exiting MIB.docx"
split_names[[11]] = "Exiting PhD.docx"
# Write output to output directory using the html_2_pandoc function
for (i in 1:length(split_names)) {
html_2_pandoc(
html = c(blocks_header_to_html(split_blocks[[i]]),
text_appendices_table(blocks = split_blocks[[i]],
original_first_row = original_first_rows,
flow = flow)),
file_name = split_names[[i]],
output_dir = output_dir
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment