kmspc {paar} | R Documentation |
MULTISPATI-PCA clustering
Description
MULTISPATI-PCA clustering
Usage
kmspc(
data,
variables,
number_cluster = 3:5,
explainedVariance = 70,
ldist = 0,
udist = 40,
center = TRUE,
fuzzyness = 1.2,
distance = "euclidean",
zero.policy = FALSE,
only_spca_results = TRUE,
all_results = FALSE
)
Arguments
data |
sf object |
variables |
variables to use for clustering, if missing, all numeric variables will be used |
number_cluster |
|
explainedVariance |
|
ldist |
|
udist |
|
center |
a logical or numeric value, centring option if TRUE, centring by the mean if FALSE no centring if a numeric vector, its length must be equal to the number of columns of the data frame df and gives the decentring |
fuzzyness |
A number greater than 1 giving the degree of fuzzification. |
distance |
|
zero.policy |
default NULL, use global option value; if FALSE stop with error for any empty neighbors sets, if TRUE permit the weights list to be formed with zero-length weights vectors |
only_spca_results |
|
all_results |
|
Value
a list with classification results and indices to select best number of clusters.
Examples
library(sf)
data(wheat, package = 'paar')
# Transform the data.frame into a sf object
wheat_sf <- st_as_sf(wheat,
coords = c('x', 'y'),
crs = 32720)
# Run the kmspc function
kmspc_results <- kmspc(wheat_sf,
number_cluster = 2:4)
# Print the summaryResults
kmspc_results$summaryResults
# Print the indices
kmspc_results$indices
# Print the cluster
head(kmspc_results$cluster, 5)
# Combine the results in a single object
wheat_clustered <- cbind(wheat_sf, kmspc_results$cluster)
# Plot the results
plot(wheat_clustered[, "Cluster_2"])