Learn R Programming

funcy (version 1.0.1)

getUniCl: Unique cluster labels

Description

For repeated measurements on the same ID, build unique cluster labels according to the vector of IDs.

Usage

getUniCl(id, clusters, reduce=TRUE)

Arguments

id

Vector of IDs.

clusters

Vector of cluster labels.

reduce

TRUE if cluster labels shall be reduced according to unique IDs. FALSE if cluster labels shall be duplicated according to IDs.

Value

A vector of either reduced (reduce=TRUE) or duplicated (reduce=FALSE) cluster labels.

Details

Data might have been stored in 4 columns: curveID, curve evaluations, time points and cluster labels. Cluster labels were therefore repeated for each curve evaluation point. Method funcit accepts dataset only in formats "Format1" and "Format2" and an optional vector of cluster true labels clusters of length nr_curves. getUniCl can be applied to columns curveID and repeated labels to reduce them to the number of curves.

Examples

Run this code
# NOT RUN {
##Generate dataset
nr_time <- sample(1:5, 100,  replace=TRUE)
clusters <- sample(1:4, 100, replace=TRUE)
IDs <- rep(1:100, nr_time)
cls <- rep(clusters,nr_time)
IDs
cls

##Get reduced cluster vector according to IDs
unicl <- getUniCl(IDs,cls)
unicl

##Get original cluster vector from reduced one
dupcl <- getUniCl(IDs,unicl, reduce=FALSE)
dupcl
# }

Run the code above in your browser using DataLab