ggsave(
filename = file.path(output_dir, "AADD_by_item.png"),
plot = p_add,
width = 8,
height = 4,
bg = "white"
)
ggsave(
filename = file.path(output_dir, "ASDD_by_item.png"),
plot = p_sub,
width = 8,
height = 4,
bg = "white"
)
ggsave(
filename = file.path(output_dir, "DD_by_group.png"),
plot = final_grouped_plot,
width = 8,
height = 6,
bg = "white"
)
ggsave(
filename = file.path(output_dir, "DMT10_by_item.png"),
plot = p_dmt10,
width = 8,
height = 4,
bg = "white"
)
ggsave(
filename = file.path(output_dir, "DMT5_by_item.png"),
plot = p_dmt5,
width = 8,
height = 4,
bg = "white"
)
ggsave(
filename = file.path(output_dir, "DD_distractors.png"),
plot = p_AADD,
width = 8,
height = 12,
bg = "white"
)
ggsave(
filename = file.path(output_dir, "ASDD_distractors.png"),
plot = p_ASDD,
width = 8,
height = 12,
bg = "white"
)
ggsave(
filename = file.path(output_dir, "AADD_accuracy.png"),
plot = p_dd_1,
width = 8,
height = 4,
bg = "white"
)
ggsave(
filename = file.path(output_dir, "ASDD_accuracy.png"),
plot = p_dd_2,
width = 8,
height = 4,
bg = "white"
)
ggsave(
filename = file.path(output_dir, "AADD_fluency.png"),
plot = p_dd_3,
width = 8,
height = 4,
bg = "white"
)
ggsave(
filename = file.path(output_dir, "ASDD_fluency.png"),
plot = p_dd_4,
width = 8,
height = 4,
bg = "white"
)
ggsave(
filename = file.path(output_dir, "DMT10_accuracy.png"),
plot = p_dmt10_acc,
width = 8,
height = 4,
bg = "white"
)
ggsave(
filename = file.path(output_dir, "DMT5_accuracy.png"),
plot = p_dmt5_acc,
width = 8,
height = 4,
bg = "white"
)
ggsave(
filename = file.path(output_dir, "DMT10_fluency.png"),
plot = p_dmt10_rcpm,
width = 8,
height = 4,
bg = "white"
)
ggsave(
filename = file.path(output_dir, "DMT5_fluency.png"),
plot = p_dmt5_rcpm,
width = 8,
height = 4,
bg = "white"
)
ggsave(
filename = file.path(output_dir, "DMT10_distractors.png"),
plot = p_dmt10,
width = 8,
height = 6,
bg = "white"
)
ggsave(
filename = file.path(output_dir, "DMT5_distractors.png"),
plot = p_dmt5,
width = 8,
height = 6,
bg = "white"
)
toc_sheets <- c(
"Clean_DD_Responses",
"Clean_DMT_Responses",
"DD_Item",
"DD_Group",
"DD_Distractors",
"DD_Score",
"DMT_Item",
"DMT_Distractors",
"DMT_Score"
)
toc_titles <- c(
"Cleaned DD responses",
"Cleaned DMT responses",
"DD: Correct vs Incorrect by Question",
"DD: Correct vs Incorrect by Question Type",
"DD: Distractor Distribution",
"DD: Accuracy & Fluency",
"DMT: Correct vs Incorrect by Question",
"DMT: Distractor Distribution",
"DMT: Accuracy & Fluency"
)
wb <- createWorkbook()
addWorksheet(wb, "Table of Contents")
writeData(
wb,
sheet = "Table of Contents",
tibble(Sheet = toc_sheets, Title = toc_titles),
withFilter = FALSE
)
for (i in seq_along(toc_sheets)) {
writeFormula(
wb,
sheet = "Table of Contents",
x = sprintf(
"HYPERLINK(\"#'%s'!A1\",\"%s\")",
toc_sheets[i],
toc_titles[i]
),
startCol = 3,
startRow = i + 1
)
}
# Cleaned DD responses
addWorksheet(wb, "Clean_DD_Responses")
writeData(wb, "Clean_DD_Responses", arithmetic_DD_df, withFilter = TRUE)
# Cleaned DMT responses
addWorksheet(wb, "Clean_DMT_Responses")
writeData(wb, "Clean_DMT_Responses", arithmetic_DMT_df, withFilter = TRUE)
# DD by question
addWorksheet(wb, "DD_Item")
writeData(wb, "DD_Item", dd_summary, withFilter = TRUE)
insertImage(
wb,
sheet = "DD_Item",
file = file.path(output_dir, "AADD_by_item.png"),
width = 6,
height = 3,
startRow = nrow(dd_summary) + 4
)
# DD by question type
addWorksheet(wb, "DD_Group")
writeData(wb, "DD_Group", dd_summary_group, withFilter = TRUE)
insertImage(
wb,
sheet = "DD_Group",
file = file.path(output_dir, "DD_by_group.png"),
width = 6,
height = 4,
startRow = nrow(dd_summary_group) + 4
)
# DD distractors
addWorksheet(wb, "DD_Distractors")
writeData(wb, "DD_Distractors", dd_prop %>% select(-pct, -flag), withFilter = TRUE)
insertImage(
wb,
sheet = "DD_Distractors",
file = file.path(output_dir, "DD_distractors.png"),
width = 6,
height = 6,
startRow = nrow(dd_prop) + 4
)
# DD Accuracy & Fluency
addWorksheet(wb, "DD_Score")
writeData(wb, "DD_Score", student_score, withFilter = TRUE)
insertImage(
wb,
sheet = "DD_Score",
file = file.path(output_dir, "AADD_accuracy.png"),
width = 6,
height = 3,
startRow = nrow(student_score) + 4
)
insertImage(
wb,
sheet = "DD_Score",
file = file.path(output_dir, "AADD_fluency.png"),
width = 6,
height = 3,
startRow = nrow(student_score) + 20
)
# DMT by question
addWorksheet(wb, "DMT_Item")
writeData(wb, "DMT_Item", dmt_summary, withFilter = TRUE)
insertImage(
wb,
sheet = "DMT_Item",
file = file.path(output_dir, "DMT10_by_item.png"),
width = 6,
height = 3,
startRow = nrow(dmt_summary) + 4
)
# DMT distractors
addWorksheet(wb, "DMT_Distractors")
writeData(wb, "DMT_Distractors", dmt_prop %>% select(-pct, -flag), withFilter = TRUE)
insertImage(
wb,
sheet = "DMT_Distractors",
file = file.path(output_dir, "DMT10_distractors.png"),
width = 6,
height = 6,
startRow = nrow(dmt_prop) + 4
)
insertImage(
wb,
sheet = "DMT_Distractors",
file = file.path(output_dir, "DMT5_distractors.png"),
width = 6,
height = 6,
startRow = nrow(dmt_prop) + 20
)
# DMT Accuracy & Fluency
addWorksheet(wb, "DMT_Score")
writeData(wb, "DMT_Score", student_score_dmt, withFilter = TRUE)
insertImage(
wb,
sheet = "DMT_Score",
file = file.path(output_dir, "DMT10_accuracy.png"),
width = 6,
height = 3,
startRow = nrow(student_score_dmt) + 4
)
insertImage(
wb,
sheet = "DMT_Score",
file = file.path(output_dir, "DMT10_fluency.png"),
width = 6,
height = 3,
startRow = nrow(student_score_dmt) + 20
)
saveWorkbook(
wb,
file = file.path(output_dir, "arithmetic_analysis.xlsx"),
overwrite = TRUE
)