# simulate some gaze data:
dat <- data.frame(
Subject = rep(1:3, 500),
Timestamp = rep(1:500, 3),
AOI = rep( rep( c('other','competitor', 'target'), 3),
c(184, 172, 144, 51, 264, 185, 127, 2, 371)) )
# add missing data:
dat[sample(nrow(dat), size=15),]$AOI <- NA
# add timebins:
dat$Timebin <- timeBins(dat$Timestamp, 100)
# calculate counts:
c1 <- getCountData('AOI', data=dat, split_by=c('Subject', 'Timebin'))
head(c1)
# calculating proportions:
c1$prop <- c1$AOI[,'target'] / ( c1$AOI[,'competitor']+c1$AOI[,'other'])
# calculating counts for specific values, including missing data.
# Note that 'distractor' is not in the data:
c2 <- getCountData('AOI', data=dat, split_by=c('Subject', 'Timebin'),
values=c('target', 'distractor', 'competitor', 'other'), incl_na=TRUE)
head(c2)
Run the code above in your browser using DataLab