meanAggregateClusterProbability: Create mean aggregate probability-of-origin surfaces for each...

View source: R/meanAggregateClusterProbability.R

meanAggregateClusterProbabilityR Documentation

Create mean aggregate probability-of-origin surfaces for each cluster.

Description

Subset probability-of-origin surfaces by cluster assignment and find mean aggregate probability-of-origin surface for each clustered group.

Usage

meanAggregateClusterProbability(indivIDs, clusters, surfaces, nClust = FALSE)

Arguments

indivIDs

Vector of individual ID variables corresponding to surface names.

clusters

Vector of cluster IDs, in an order corresponding to 'indivIDs'.

surfaces

SpatRaster of probability-of-origin surfaces for all individuals.

nClust

Depreciated. Formerly enabled multi-core processing; retained for back-compatibility. A non-'FALSE' value now issues a message and proceeds serially.

Examples


# Create and cluster example assignment surfaces.
myiso <- rast(isoscape, type="xyz")
myiso_sd <- rast(isoscape_sd, type="xyz")
df <- data.frame(
        ID = LETTERS[1:9],
        isotopeValue = seq(-120,-25,length.out = 9),
        SD_indv = rep(5, 9)
        )
assignmentModels <- isotopeAssignmentModel(
         ID = df$ID,
         isotopeValue = df$isotopeValue,
         SD_indv = df$SD_indv,
         precip_raster = myiso,
         precip_SD_raster = myiso_sd,
         nClusters = FALSE
         )
mySimilarityMatrix <- surfaceSimilarityMatrix(assignmentModels)
cS <- clusterSimmatrix(
         simmatrix = mySimilarityMatrix,
         r = seq(.7,1.4,by=.1)
         )
# Cut clusters.
myheight <- 0.25
df$cluster <- dendextend::cutree(cS$hclust, h = myheight)
# Create mean aggregate surfaces.r p
meanSurfaces <- meanAggregateClusterProbability(
         indivIDs = df$ID,
         clusters = df$cluster,
         surfaces = assignmentModels,
         nClust = FALSE
         )


isocat documentation built on July 9, 2026, 5:10 p.m.