plot_defective_density {EMC2} | R Documentation |
Plots panels that contain a set of densities for each response option in the data. These densities are defective; their areas are relative to the respective response proportion. Across all responses, the area sums to 1.
plot_defective_density(
data,
subject = NULL,
factors = NULL,
layout = NA,
correct_fun = NULL,
rt_pos = "top",
accuracy = "topright",
...
)
data |
A data frame. The experimental data in EMC2 format with at least |
subject |
An integer or character string selecting a subject from the data.
If specified, only that subject is plotted. Per default (i.e., |
factors |
A character vector of the factor names in the design to aggregate across
Defaults to all (i.e., |
layout |
A vector indicating which layout to use as in par(mfrow = layout). If NA, will automatically generate an appropriate layout. |
correct_fun |
If specified, the accuracy for each subject is calculated, using the supplied function and an accuracy vector for each subject is returned invisibly. |
rt_pos |
legend function position character string for the mean response time (defaults to |
accuracy |
legend function position character string for accuracy (defaults to |
... |
Optional arguments that can be passed to |
If correct_fun
is specified, a subject accuracy vector is returned invisibly
# First for each subject and the factor combination in the design:
plot_defective_density(forstmann)
# Now collapsing across subjects:
plot_defective_density(forstmann, factors = c("S", "E"))
# If the data is response coded, it generally makes sense to include the "S" factor
# because EMC2 will plot the "R" factor automatically. This way, choice accuracy can
# be examined
# Each subject's accuracy can be returned using a custom function:
print(plot_defective_density(forstmann, correct_fun = function(d) d$R == d$S))