centroidssummary: Returns Centroids summary

Description Usage Arguments Value Author(s) Examples

View source: R/centroidssummary.R

Description

Returns Centroid summary

Usage

1
centroidssummary(clustereddata)

Arguments

clustereddata

original dataframe

Value

centroid

Author(s)

Kaloyan S, kaloyanS@profusion.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (clustereddata) 
{
    colnames(clustereddata)[(length(clustereddata))] <- "cluster_number"
    centroids <- aggregate(clustereddata, by = list(clustereddata$cluster_number), 
        FUN = mean)
    clustereddata$counts <- 1
    centroids <- cbind(centroids, aggregate(counts ~ cluster_number, 
        data = clustereddata, FUN = sum))
    centroids <- centroids[, c((length(df) + 2), 2:(length(df) + 
        1), (length(df) + 4))]
    return(centroids)
  }

Example output

function (clustereddata) 
{
    colnames(clustereddata)[(length(clustereddata))] <- "cluster_number"
    centroids <- aggregate(clustereddata, by = list(clustereddata$cluster_number), 
        FUN = mean)
    clustereddata$counts <- 1
    centroids <- cbind(centroids, aggregate(counts ~ cluster_number, 
        data = clustereddata, FUN = sum))
    centroids <- centroids[, c((length(df) + 2), 2:(length(df) + 
        1), (length(df) + 4))]
    return(centroids)
}

hkclustering documentation built on May 2, 2019, 6:37 a.m.