Last data update: 2014.03.03

R: Converts label vector to 0/1 mixture weight matrix
states2weight_matrixR Documentation

Converts label vector to 0/1 mixture weight matrix

Description

Converts unique cluster assignment stored in a length N label vector into a N \times K Boolean matrix of mixture weights.

Usage

states2weight_matrix(states, num.states.total = NULL)

Arguments

states

a vector of length N with the state labels

num.states.total

total number of states. If NULL, then the maximum of states is chosen

See Also

weight_matrix2states

Examples

ss <- sample.int(5, 10, replace = TRUE)
WW <- states2weight_matrix(ss)

image2(WW, col = "RdBu", xlab = "States", ylab = "Samples", axes = FALSE)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(LICORS)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/LICORS/states2weight_matrix.Rd_%03d_medium.png", width=480, height=480)
> ### Name: states2weight_matrix
> ### Title: Converts label vector to 0/1 mixture weight matrix
> ### Aliases: states2weight_matrix
> ### Keywords: array manip
> 
> ### ** Examples
> 
> ss <- sample.int(5, 10, replace = TRUE)
> WW <- states2weight_matrix(ss)
> 
> image2(WW, col = "RdBu", xlab = "States", ylab = "Samples", axes = FALSE)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>