by.trackdata {emu} | R Documentation |
A given function 'FUN' is applied to the data corresponding to each segment of data.
## S3 method for class 'trackdata': by(data, INDICES=NULL,FUN, ..., simplify = FALSE )
data |
a track data object |
INDICES |
|
FUN |
a function that is applied to each segment |
... |
arguments of the function fun |
simplify |
simplify = TRUE , output is a matrix; simplify = FALSE a list is returned |
It is the same as trapply but with the extension to subsume calculation to groups of segments. Note, if you do not want to apply the function fun to a special group of segments, use trapply instead.
list or vector
Jonathan Harrington
trapply
,
by
,
trackdata
dapply
smooth
apply
data(demo.vowels) data(demo.vowels.fm) #mean F1 subsumed for each vowel ################################ lab = label(demo.vowels) by(demo.vowels.fm[,1], lab ,mean ,simplify=FALSE) #mean F1 subsumed for segment onsets mids and offsets ############################################## data = demo.vowels.fm llabs = NULL for (ind in 1:dim(data$ftime)[1]) { seglabs = rep("mid",data$index[ind,2]-data$index[ind,1]+1) seglabs[1] = "on" seglabs[length(seglabs)] = "off" llabs = as.vector(c(llabs , seglabs)) } by(demo.vowels.fm[,1], llabs , mean , simplify=FALSE) #mean F1 subsumed for segment onsets mids and offsets subsumed for each vowel ##################################################################### by(demo.vowels.fm[,1], list(lab = lab, llabs = llabs) , mean , simplify=FALSE)