Description Usage Arguments Value Implementation Examples
Sets the first component of dimnames(x)
1 | setRowNames(x, rowNames)
|
x |
A matrix, array or data frame |
rowNames |
New names for rows |
Input x with new row names
Alternative way, does not work for data.frame:
function(x, rowNames) return(structure(x, dimnames=c(list(rowNames), dimnames(x)[-1])))
1 2 3 4 5 6 | setRowNames(matrix(1:4, nrow=2, ncol=2), c("a","b"))
setRowNames(matrix(1:4, nrow=2, ncol=2), NULL)
setRowNames(array(1:8, dim=c(2,2,2)), c("a","b"))
setRowNames(as.data.frame(matrix(1:4, nrow=2, ncol=2)), c("a","b"))
## Not run: setRowNames(as.data.frame(matrix(1:4, nrow=2, ncol=2)), NULL) # Is this a BUG?!
## Not run: setRowNames(1:2, c("a","b")) # Error 'dimnames' applied to non-array
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.