Description Usage Arguments Details Value Note Author(s) References See Also Examples
Change selected element names.
1 | colname(x) <- value
|
x |
an object with named elements |
value |
named character vector |
Changing column names is a common task. One can change them all at once, e.g.
colnames(x) <- c(...)
names(x) <- c(...)
or one at a time, e.g.
names(x)[names(x)==old] <- new
reshape supplies rename
, a function that changes a subset of
identified names, returning the object itself.
library(reshape)
x <- rename(x, c(label=value,...))
In contrast, name
and its data frame equivalent colname
change a
subset of identified names using assignment syntax.
name(x) <- c(label=value,...)
used for side effects
In some cases the column name being replaced must be quoted for the replacement to work. For example, when running colname
to replace a column name that contains a special character like '_' or '*', it is necessary to place quotes around the column name.
Tim Bergsma
https://r-forge.r-project.org/R/?group_id=1215
names
colnames
1 2 3 4 5 6 7 8 9 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.