Diag: Equality of Two or More Factors

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

View source: R/Diag.R

Description

Converts two or more factors into a new factor whose value is 0 where the original factors are not all equal, and nonzero otherwise.

Usage

1
Diag(..., binary = FALSE)

Arguments

...

One or more factors

binary

Logical

Details

Used mainly in regression models for data classified by two or more factors with the same levels. By default, operates on k-level factors to produce a new factor having k+1 levels; if binary = TRUE is specified, the result is a coarser binary variable equal to 1 where all of the input factors are equal and 0 otherwise.

Value

Either a factor (if binary = FALSE) or a 0-1 numeric vector (if binary = TRUE).

Author(s)

David Firth and Heather Turner

See Also

Symm

Examples

1
2
3
4
row <- gl(4, 4, 16)
col <- gl(4, 1, 16)
diag4by4 <- Diag(row, col)
matrix(Diag(row, col, binary = TRUE), 4, 4)

gnm documentation built on May 29, 2017, 2:22 p.m.

Search within the gnm package
Search all R packages, documentation and source code