View source: R/plotDistractor_gg.R
| plotDistractor_gg | R Documentation |
Creates stacked bar charts showing the proportion of each response category by rank/class for each item. The correct answer category is highlighted in a distinct color to visualize how well each item discriminates across ability levels.
plotDistractor_gg(
data,
items = NULL,
ranks = NULL,
title = TRUE,
colors = NULL,
show_legend = TRUE,
legend_position = "right"
)
data |
An object of class |
items |
Integer vector of item indices to plot. If |
ranks |
Integer vector of rank/class indices to display.
If |
title |
Logical or character. If |
colors |
Character vector of colors for response categories. If
|
show_legend |
Logical. If |
legend_position |
Character. Position of the legend. One of
|
Distractor Analysis examines how examinees in different ability ranks or latent classes respond to multiple-choice items. For each item, a stacked bar chart shows the proportion of respondents choosing each category.
A well-functioning item should show the correct answer category (highlighted in blue by default) increasing in proportion as rank/class increases, while distractor categories decrease.
This function works with DistractorAnalysis objects produced from
LRA (rated data) and Biclustering / Biclustering_IRM
(rated data) results.
A named list of ggplot objects, one per item. Names correspond to item labels.
plotIRP_gg, plotFCRP_gg,
combinePlots_gg
library(exametrika)
# LRA.rated example
result_lra <- LRA(J21S300, nrank = 5, mic = TRUE)
da <- DistractorAnalysis(result_lra)
# Plot a single item
plots <- plotDistractor_gg(da, items = 1)
plots[[1]]
# Plot multiple items
plots <- plotDistractor_gg(da, items = 1:6)
combinePlots_gg(plots, selectPlots = 1:6)
# Select specific ranks
plots <- plotDistractor_gg(da, items = 1, ranks = c(1, 3, 5))
# Custom colors
plots <- plotDistractor_gg(da,
items = 1,
colors = c("tomato", "steelblue", "gold", "gray70")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.