pair.counts: Count Pairs in Character Vectors

View source: R/counting.R

pair.countsR Documentation

Count Pairs in Character Vectors

Description

Count pairs of adjacent symbols/elements in a character vector.

Usage

pair.counts(x, case=c("lower", "upper", "as is"), circular=TRUE)

Arguments

x

a character vector or an object that can be coersed to a character vector.

case

determines how labels for the array should be generated: in 'lower' case, in ' upper' case or 'as is', in which case labels such as 'b' and 'B' will be considered as distinct elements and counted separately.

circular

Determines if the vector should be treated as circular or not. The default is TRUE, meaning that the start and end of the sequence will be joined together for the purpose of counting.

Details

When circular is TRUE, the vector is treated as circular so that the some of all the counts in the resulting matrix is equal to the length of the vector and the row and column sums are equivalent. When circular is FALSE, the sum of all the entries in the counts matrix will be one less than the length of the vector and there will be a discrepancy between the row and column sums.

Value

A matrix of counts. The row and column labels correspond to the first and second element of each pair, respectively.

Author(s)

Andrew Hart and Servet Martínez

See Also

triple.counts, quadruple.counts, cylinder.counts, array2vector, table2vector


spgs documentation built on Oct. 3, 2023, 5:07 p.m.