## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.align = "center",
  fig.width = 7,
  fig.height = 5,
  out.width = "85%"
)
library(mcqAnalysis)

## ----install-cran, eval = FALSE-----------------------------------------------
# install.packages("mcqAnalysis")

## ----install-gh, eval = FALSE-------------------------------------------------
# # install.packages("devtools")
# devtools::install_github("Rafhq1403/mcqAnalysis")

## ----data---------------------------------------------------------------------
data(mcq_example)
str(mcq_example, max.level = 1)
mcq_example$key[1:6]
head(mcq_example$responses[, 1:6])

## ----main---------------------------------------------------------------------
result <- mcq_analysis(mcq_example$responses, mcq_example$key)
result

## ----plot---------------------------------------------------------------------
plot(result)

## ----plot-variants, eval = FALSE----------------------------------------------
# plot(result, label = "all")
# plot(result, discrimination_metric = "discrimination_index")

## ----distractors--------------------------------------------------------------
da <- distractor_analysis(mcq_example$responses, mcq_example$key)
head(da, 8)

## ----item30-------------------------------------------------------------------
da[da$item == "item30", ]

## ----de-----------------------------------------------------------------------
de <- distractor_efficiency(mcq_example$responses, mcq_example$key)
de[1:10]

## ----apa-df-------------------------------------------------------------------
apa_table(result, format = "data.frame")[1:8, ]

## ----apa-md, eval = FALSE-----------------------------------------------------
# apa_table(result, format = "markdown")

## ----individual---------------------------------------------------------------
item_difficulty(mcq_example$responses, mcq_example$key)[1:6]
point_biserial(mcq_example$responses, mcq_example$key)[1:6]
item_discrimination(mcq_example$responses, mcq_example$key,
                    method = "discrimination_index")[1:6]

