density_by: Calculate Eye Density by Groups

View source: R/density.R

density_byR Documentation

Calculate Eye Density by Groups

Description

This function calculates the eye density for fixations, grouped by specified variables.

Usage

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",
  ...
)

Arguments

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.

Value

A data frame containing the original grouping variables, the fixations, and the density result.

Examples

# 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")


bbuchsbaum/eyesim documentation built on May 9, 2023, 3:29 a.m.