Learn R Programming

multcompView (version 0.1-10)

vec2mat2: Convert a vector of hyphenated names into a character matrix.

Description

Convert a vector of hyphenated names into a character matrix with 2 columns containing the names split in each row.

Usage

vec2mat2(x, sep = "-")

Value

A character matrix with rownames = x and with the character string preceding the "sep" character in the first column and the character string following the "sep" character in the second column.

Arguments

x

Vector of hyphenated names

sep

"strsplit" character to apply to names(x).

Author

Spencer Graves

Details

If each element of x does not contain exactly 1 "sep" character, an error is issued.

See Also

vec2mat multcompLetters

Examples

Run this code

vec2mat2(c("a-b", "a-c", "b-c"))

vec2mat2(c("a-b", "b-a"))

# \dontshow{
(tst3 <- substring(try(
 vec2mat2(c("a", "b-a", "b-c"))), 1, 20)
=="Error in vec2mat2(c(")
# Error:  name without a sep character 

(tst4 <- substring(try(
 vec2mat2(c("a-c", "b-a", "b-c-d"))), 1, 20)
=="Error in vec2mat2(c(")
# Error:  multiple hyphens (sep characters)

# } 

Run the code above in your browser using DataLab