colname: Change Selected Names

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Change selected element names.

Usage

1
colname(x) <- value

Arguments

x

an object with named elements

value

named character vector

Details

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,...)

Value

used for side effects

Note

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.

Author(s)

Tim Bergsma

References

https://r-forge.r-project.org/R/?group_id=1215

See Also

Examples

1
2
3
4
5
6
7
8
9
names(Theoph)
name(Theoph) <- c(Subject='SUBJECT')
names(Theoph)
colname(Theoph) <- c(SUBJECT='subject',conc='concentration')
names(Theoph)
names(letters) <- LETTERS
letters
name(letters) <- c(A='a',B='b',C='c')
letters

metrumrg documentation built on May 2, 2019, 5:55 p.m.