Learn R Programming

dst (version 1.3.0)

nameRows: Using the column names of a matrix to construct names for the rows

Description

This function determines the name of a row from all the columns that have a 1 for that row.

Usage

nameRows(f)

Arguments

f

A (0,1)-matrix or a boolean matrix.

Value

The result is a character vector of the labels proposed for the rows of the matrix f. The length of the result is nrow(f).

Details

The row containing all one's is called "frame", to avoid too long a character string. The empty set is named by its code "u00f8". The "+" sign is used to represent the logical "or" operator. The space " " is used to represent the logical "and" operator. Note that in the case of a product space defined on many variables, row labels will be very long.

Examples

Run this code
# NOT RUN {
f <- matrix(c(0,0,0,1,0,0,0,0,1,1,0,1,1,1,1),ncol=3, byrow = TRUE)
colnames(f) <- c("A","B","C")
rownames(f) <-nameRows(f)
f
f2 <- matrix(c(0,0,0,1,0,0,0,0,1,1,0,1),ncol=3, byrow = TRUE)
colnames(f2) <- c("A2","B2","C2")
rownames(f2) <-nameRows(f2) 
f2
# }

Run the code above in your browser using DataLab