This function reliably returns integer names if present, otherwise character dimnames. Use this instead of colnames() if you need guaranteed dispatch.
Usage
col_names(x)
# Default S3 method
col_names(x)
# S3 method for class 'matrix_int_names'
col_names(x)
col_names(x) <- value
# Default S3 method
col_names(x) <- value
# S3 method for class 'matrix_int_names'
col_names(x) <- valueSee also
Other matrix_int_names_functions:
[.matrix_int_names(),
as.data.frame.matrix_int_names(),
matrix_int_names(),
print.matrix_int_names(),
row_names()
Examples
my_mat <- matrix_int_names(matrix(1:6, nrow = 2),
row_names = c(10L, 20L),
col_names = c(100L, 200L, 300L)
)
col_names(my_mat)
#> [1] 100 200 300
# set character names instead
col_names(my_mat) <- c("a", "b", "c")
col_names(my_mat)
#> [1] "a" "b" "c"
