dat.sel: Generate Pairwise Data Set

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/mt_util.R

Description

Generate index or data set of pairwise combination based on class labels.

Usage

1
2
3
  combn.pw(cls, choices = NULL) 
  
  dat.sel(dat, cls, choices = NULL)

Arguments

dat

A data frame or matrix of data set.

cls

A factor or vector of class labels or categorical data.

choices

The vector or list of class labels to be chosen for binary combination.

Details

If choices is NULL, all binary combinations will be computed. If choices has one class label, the comparisons between this one and any other classes will be calculated. If choices has more than two classes, all binary combinations in choices will be generated. For details, see examples below.

Value

combn.pw returns a data frame of index (logical values).

dat.set returns a list of list with components:

dat

Pairwise data set.

cls

Pairwise class label.

Author(s)

Wanchang Lin

See Also

Applications of dat.sel in pca.plot.wrap, lda.plot.wrap and pls.plot.wrap.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
data(iris)
x <- subset(iris, select = -Species)
y <- iris$Species
 
## generate data set with class "setosa" and "virginica"
binmat.1 <- dat.sel(x,y,choices=c("setosa","virginica"))
names(binmat.1)

## generate data sets for "setosa" vs other classes. These are: 
## "setosa" and "versicolor", "setosa" and "virginica".
binmat.2 <- dat.sel(x,y,choices=c("setosa"))
names(binmat.2)

## generate data set with combination of each class. These are:  
## "setosa" and "versicolor", "setosa" and "virginica",  
## "versicolor" and "virginica" 
binmat.3 <- dat.sel(x,y,choices= NULL)
names(binmat.3)

data(abr1)
cls <- factor(abr1$fact$class)
dat <- preproc(abr1$pos, method="log")

## There are some examples of 'choices'
choices <- c("2")
choices <- c("2","3","4")
choices <- list(c("2","3"),c("4","5"))
choices <- NULL
idx <- combn.pw(cls,choices=choices)  

dat.pw <- dat.sel(dat, cls,choices=choices)

mt documentation built on Feb. 2, 2022, 1:07 a.m.

Related to dat.sel in mt...