Learn R Programming

pooledpeaks (version 1.1.1)

cluster: K-means Clustering

Description

K-means Clustering

Usage

cluster(RawData = data.frame, K = 2)

Value

A list containing the results of the K-means cluster analysis, including cluster assignments and original data.

Arguments

RawData

A data frame containing the raw data as read in by LoadData

K

An integer specifying the number of clusters.

Examples

Run this code
genetic_data <- data.frame(
Locus = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2),
Locus_allele = c("Marker1", "n", 1, 2, 3, "Marker2", "n", 1, 2, 3),
Sample1 = c(NA, 10, 0.5, 0.5, 0, NA, 10, 0.2, 0.3, 0.5),
Sample2 = c(NA, 20, 0.1, 0.2, 0.7, NA, 20, 0.3, 0.4, 0.3),
Sample3 = c(NA, 30, 0.3, 0.4, 0.3, NA, 30, 0.4, 0.2, 0.4)
)
cluster(RawData=genetic_data, K=2)

Run the code above in your browser using DataLab