density_by | R Documentation |
This function calculates the eye density for fixations, grouped by specified variables.
density_by(
x,
groups,
sigma = 50,
xbounds = c(0, 1000),
ybounds = c(0, 1000),
outdim = c(100, 100),
duration_weighted = TRUE,
window = NULL,
keep_vars = NULL,
fixvar = "fixgroup",
result_name = "density",
...
)
x |
A data frame containing fixations and additional grouping variables. |
groups |
A character vector specifying the grouping variables to use. |
sigma |
A numeric value specifying the bandwidth for the kernel density estimation (default is 50). |
xbounds |
A numeric vector of length 2 specifying the x-axis bounds for the density calculation (default is c(0, 1000)). |
ybounds |
A numeric vector of length 2 specifying the y-axis bounds for the density calculation (default is c(0, 1000)). |
outdim |
A numeric vector of length 2 specifying the dimensions of the output density matrix (default is c(100, 100)). |
duration_weighted |
A logical value indicating whether the density should be weighted by fixation duration (default is TRUE). |
window |
A numeric vector of length 2 specifying the time window for selecting fixations (default is NULL). |
keep_vars |
A character vector specifying additional variables to keep in the output (default is NULL). |
fixvar |
A character string specifying the name of the fixation variable (default is "fixgroup"). |
result_name |
A character string specifying the name for the density result variable (default is "density"). |
... |
Additional arguments passed to the 'eye_density' function. |
A data frame containing the original grouping variables, the fixations, and the density result.
# Create a data frame with fixations and a grouping variable
fixations <- data.frame(
subject = rep(c("A", "B"), each = 25),
x = runif(50, 0, 1000),
y = runif(50, 0, 1000),
duration = rep(1, 50),
onset = seq(1, 50)
)
# Calculate eye density by subject
result <- density_by(fixations, groups = "subject")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.