Automatically detect row names column, if defined.

matchRowNameColumn(object, ...)

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

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

Arguments

object

Object.

...

Additional arguments.

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.

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 2019-10-22.

Examples

data(data.table, tbl_df, package = "acidtest") ## data.table ==== matchRowNameColumn(data.table)
#> [1] "rn"
## tbl_df ==== matchRowNameColumn(tbl_df)
#> [1] "rowname"