Last chance! 50% off unlimited learning
Sale ends in
getSegments(x, f = NULL, cutoff = quantile(abs(x), 0.99), assumeSorted = FALSE, verbose = FALSE)
x
into pieces. Each
piece is then segmented based on the cutoff. Setting this to
NULL
says that there is no pre-division. Often,
clusterMaker
is used to define this factor.f
is sorted. Allowing the function to make
this assumption may increase the speed of the function slightly.x
and f
.
x
above U.x
below L.x
between L and U.bumphunter
. x
is a numeric vector, which is converted into three levels
depending on whether x>=U (‘up’), Lx
are next to each other in some
sense. Segments, consisting of consecutive indices into x
(ie. values between 1 and length(x)
), are formed such that all
indices in the same segment belong to the same level of f
and
have the same discretized value of x
.
In other words, we can use getSegments
to find runs of x
belonging to the same level of f
and with all of the values of
x either above U, between L and U, or below L.
clusterMaker
x <- 1:100
y <- sin(8*pi*x/100)
chr <- rep(1, length(x))
indexes <- getSegments(y, chr, cutoff=0.8)
plot(x, y, type="n")
for(i in 1:3){
ind <- indexes[[i]]
for(j in seq(along=ind)) {
k <- ind[[j]]
text(x[k], y[k], j, col=i)
}
}
abline(h=c(-0.8,0.8))
Run the code above in your browser using DataLab