#' A general IRT summary for new R users.
#' @param data A P x N data.frame of dichotomously scored data, where P is the number of examinees and N is the number of items.
#' There should only be scored data in the dataset(i.e. no student identifiers).
#' @param title A character string to use as the title of the report.
#' @param note A note to include about the report.
#' @param author A character string to insert under the title in the report.
#' @export
irt_summarize <- function(data, title, author, note = ''){
message("\nGenerating Report...\n")
fileConn<-file("irt_summarize_output.Rmd")
writeLines(c("---",
"output: ",
" html_document:",
" toc: true",
" toc_float: true",
"params:",
" title: 'New Report'",
" author: 'wizirt'",
" note: ''",
" data: ''",
"---",
"",
"---",
"title: `r params$title`",
"subtitle: `r params$notes`",
"author: `r params$author`",
"date: `r format(Sys.time(), '%B %d, %Y, %H:%M %p')`",
"---",
"",
"```{r echo = FALSE, message=FALSE, warning = FALSE}",
"knitr::opts_chunk$set(",
" echo = FALSE, message = FALSE",
")",
"",
"out <- wizirt2::irt(item_type = 'Rasch') %>%",
" parsnip::set_engine('mirt') %>% ",
" wizirt2::fit_wizirt(data = params$data)",
"pfa <- wizirt2::irt_person_fit(out, stats = 'Ht')",
"ifa <- irt_item_fit(out, stats = 'infit')",
" ",
"```",
"",
"# Test Overview",
"",
"## Test Information Function",
"",
"```{r}",
"wizirt2:::plot.irt(out, type = 'info')",
"```",
"",
"### Distribution of Person Ability Estimates",
"",
"```{r}",
"wizirt2:::plot.irt(out, type = 'theta')",
"```",
"",
"## Estimation",
"",
"```{r}",
"DT::datatable(wizirt2:::print.irt(out, type = 'tech'))",
"```",
"",
"## Data",
"",
"```{r}",
"DT::datatable(wizirt2:::print.irt(out, type = 'desc'))",
"```",
"",
"<!-- ## Assumptions {.tabset} -->",
"",
"<!-- ### Unidimensionality -->",
"",
"<!-- Coming soon -->",
"",
"<!-- ### Model-Data Fit -->",
"",
"<!-- ### Local Dependence -->",
"",
"# Item-Level Fit",
"",
"## Item Characteristic Curves",
"",
"```{r}",
"wizirt2:::plot.ifa(ifa, type = 'trace')",
"```",
"",
"## Item Information",
"",
"```{r}",
"wizirt2:::plot.ifa(ifa, type = 'info')",
"```",
"",
"## Item Statistics",
"",
"```{r}",
"DT::datatable(wizirt2:::print.ifa(ifa))",
"```",
"",
"# Person-Level Fit",
"",
"## Person Response Functions",
"",
"```{r, warning=FALSE}",
"wizirt2:::plot.pfa(pfa)",
"```",
"",
"## Person Statistics",
"",
"```{r}",
"DT::datatable(wizirt2:::print.pfa(pfa, patterns = TRUE))",
"```"
), fileConn)
close(fileConn)
rmarkdown::run("irt_summarize_output.Rmd", render_args = list(params = list(
author = author,
title = title,
note = note,
data = data
)))
browseURL(paste0('file://', file.path(getwd(), "irt_summarize_output.html")))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.