# NOT RUN {
# Function script ----
xy <- c(1,0,0,0,4,5,5,0.5,-0.5,0.5,0,2,2,1,-1,-1,1,1,0,0,-4,-2,2,1,0,0.5,0,
NA, 0.5,0,-0.5,3,2,3,0,0.5,4,4,0)
impressme <- 0 # Increase up to 5 or 6 to be impressed (bugs if your system
# can't handle the size of the data).
# If you increase it, do not run the plot script.
xy <- rep(xy, round(10^impressme))
print(paste("You are running ", length(xy), " points", sep = ""))
res <- extremist(xy)
# Plot script: do not run if you increase the impressme parameter ----
mini <- unique(c(res$minindex[[1]], res$minindex[[2]]))
maxi <- unique(c(res$maxindex[[1]], res$maxindex[[2]]))
zeri <- unique(c(res$cross[[1]], res$cross[[2]]))
l <- length(xy)
opar <- par("mfrow")
par(mfrow = c(3,1))
plot(1:l, xy, type = "o",pch = 19)
points(mini, xy[mini], pch = 19, col = "blue")
plot(1:l, xy, type = "o",pch = 19)
points(maxi, xy[maxi], pch = 19, col = "red")
plot(1:l, xy, type = "o",pch = 19)
points(zeri, xy[zeri], pch = 19, col = "green")
abline(h = 0, col = "grey")
par(mfrow = opar)
# }
Run the code above in your browser using DataLab