Skip to content

Instantly share code, notes, and snippets.

@markushuff
Last active December 4, 2021 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markushuff/b8af1d3931050cfc2c628e2199a3d10b to your computer and use it in GitHub Desktop.
Save markushuff/b8af1d3931050cfc2c628e2199a3d10b to your computer and use it in GitHub Desktop.
Get a list including the n highest event boundaries of a segmag object (Papenmeier, 2016; https://cran.r-project.org/package=segmag). Sometimes it is necessary to get just a list of the n highest event boundaries w/o doing the time consuming bootstrapping method. Note, this function requires the segmag package.
get_n_eb_times <- function(n, segmag)
{
eb_times <- get_eb_times(segmag,
cutoff = mean(segmag$data$segmentation_magnitude))
out <- segmag$data[segmag$data$time %in% eb_times, ]
out <- out[order(out$segmentation_magnitude, decreasing = TRUE),]
out[1:n,]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment