by.trackdata {emuR} | R Documentation |
A method of the generic function by for objects of class 'trackdata'
Description
A given function 'FUN' is applied to the data corresponding to each segment of data.
Usage
## S3 method for class 'trackdata'
by(data, INDICES = NULL, FUN, ..., simplify = FALSE)
Arguments
data |
a track data object |
INDICES |
a list of segment indices, like a label vector |
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 |
Details
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.
Value
list or vector
Author(s)
Jonathan Harrington
See Also
trapply
, by
, trackdata
dapply
smooth
apply
Examples
data(demo.vowels)
data(demo.vowels.fm)
#mean F1 subsumed for each vowel
################################
lab = label(demo.vowels)
by(demo.vowels.fm[,1], lab ,sapply,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 , sapply, 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) , sapply, mean , simplify=FALSE)
[Package emuR version 2.5.0 Index]