nPairs {gdata}R Documentation

Number of variable pairs

Description

nPairs counts the number of pairs between variables.

Usage

nPairs(x, margin=FALSE, names=TRUE, abbrev=TRUE, ...)

Arguments

x data.frame or a matrix
margin logical, calculate the cumulative number of “pairs”
names logical, add row/col-names to the output
abbrev logical, abbreviate names
... other arguments passed to abbreviate

Value

Matrix of order k, where k is the number of columns in x. Values in a matrix represent the number of pairs between columns/variables in x. If margin=TRUE, the number of columns is k+1 and the last column represents the cumulative number of pairing all variables.

Author(s)

Gregor Gorjanc

See Also

abbreviate

Examples


## Test data
test <- data.frame(V1=c(1, 2, 3, 4, 5),
                   V2=c(NA, 2, 3, 4, 5),
                   V3=c(1, NA, NA, NA, NA),
                   V4=c(1, 2, 3, NA, NA))

## Number of variable pairs
nPairs(x=test)

## Without names
nPairs(x=test, names=FALSE)

## Longer names
colnames(test) <- c("Variable1", "Variable2", "Variable3", "Variable4")
nPairs(x=test)

## Margin
nPairs(x=test, margin=TRUE)


[Package gdata version 2.6.1 Index]