Skip to contents

Automatically detect row names column, if defined.

Usage

matchRownameColumn(object, ...)

# S4 method for DataFrame
matchRownameColumn(
  object,
  choices = c("rn", "row.name", "row.names", "rowname", "rownames")
)

# S4 method for data.frame
matchRownameColumn(
  object,
  choices = c("rn", "row.name", "row.names", "rowname", "rownames")
)

Arguments

object

Object.

choices

character. Column name choices to use internally for matching. Note that case-insensitive matching is performed against make.names() return internally. Either dots (".") or underscores ("_") used as word separators will match.

...

Additional arguments.

Value

character(1) or NULL.

  • data.table: "rn".

  • tibble: "rowname".

Details

The data.table package uses "rn" by default, whereas tibble uses "rowname".

Note

Updated 2021-10-14.

Examples

## data.table ====
if (requireNamespace("data.table", quietly = TRUE)) {
    data(data.table, package = "AcidTest")
    object <- data.table
    matchRownameColumn(object)
}
#> [1] "rn"

## tbl_df ====
if (requireNamespace("tibble", quietly = TRUE)) {
    data(tibble, package = "AcidTest")
    object <- tibble
    matchRownameColumn(object)
}
#> [1] "rowname"