medoidSP: Find the medoid snow profile among a group of profiles

View source: R/medoidSP.R

medoidSPR Documentation

Find the medoid snow profile among a group of profiles

Description

Find the medoid snowprofile among a group of profiles, based on their pairwise dissimilarity. Either provide a list of snowprofile objects, or a precomputed distance matrix.

Usage

medoidSP(SPx, distmat = NULL, clustering = NULL, keepDistmat = FALSE, ...)

Arguments

SPx

a sarp.snowprofile::snowprofileSet object

distmat

If you have a precalculated distance matrix, provide it here to compute the medoid on it.

clustering

index of clusters, if provided instead of identifying the medoid profile of the entire snowprofileSet it will return a vector of medoids for each cluster

keepDistmat

Do you want to return the pairwise distance matrix?

...

arguments passed to distanceSP and then further to dtwSP and simSP

Details

If providing a large number of profiles without a precomputed distance matrix consider providing a ncores argument so distanceSP will calculate alignments in parallel.

Value

If keepDistmat = FALSE return the (named) index of the medoid snow profile, otherwise return a list with the elements id.med and distmat.

Author(s)

fherla shorton

Examples

this_example_runs_about_5s <- TRUE
if (!this_example_runs_about_5s) {  # exclude from cran checks

## take a list of profiles
grouplist <- SPgroup2[1:4]
plot(grouplist, SortMethod = 'unsorted', xticklabels = "originalIndices")

## calulate medoid profile
id.med <- medoidSP(grouplist)
representativeProfile <- grouplist[[id.med]]
plot(representativeProfile, main = paste0("medoid (i.e., profile ", id.med, ")"))

}

sarp.snowprofile.alignment documentation built on Sept. 11, 2024, 9:23 p.m.