check-scalar-hasRownames: Does the input have row names?

check-scalar-hasRownamesR Documentation

Does the input have row names?

Description

Does the input have row names?

Usage

hasRownames(x)

Arguments

x

Object.

Value

TRUE on success; FALSE on failure, with cause set.

data.frame

Standard data.frame class objects cannot have NULL row names defined. Here we are checking to see if a data.frame has soft NULL row names, meaning that they return as a sequence that is identical to the number of rows.

Note

Updated 2022-12-14.

Examples

## TRUE ====
x <- data.frame(
    "sample1" = c(1L, 2L),
    "sample2" = c(3L, 4L),
    row.names = c("gene1", "gene2")
)
print(x)
hasRownames(x)

## FALSE ====
x <- data.frame(a = seq_len(2L))
print(x)
# Standard data frame doesn't allow NULL row names.
rownames(x)
hasRownames(x)

x <- S4Vectors::DataFrame(a = seq_len(2L))
print(x)
# S4 data frame does allow NULL row names.
rownames(x)
hasRownames(x)

acidgenomics/r-goalie documentation built on Jan. 12, 2024, 4:15 a.m.