| cbind.colnames {cwhmisc} | R Documentation |
cbind.colnames adds columns to a given data frame. The names of the
variables to be added are given in character vector add.
cbind.colnames(add,to=NULL,deparse.level = 1)
to |
Matrix to be augmented. |
add |
Vector of names of variables to be added to to as
columns. |
deparse.level |
Usually 1, See cbind |
Combined matrix. The column names are the concatenation of those of
to and add. Row names are taken from to.
Uses get to access the variables listed in add.
If the new variables have wrong lenghts, an error will result.
Christian W. Hoffmann <c-w.hoffmann@sunrise.ch>
http://www.wsl.ch/personal_homepages/hoffmann/index_EN
d <- data.frame(E = c("D","at","a"),w = c(11,22,33))
x <- c(2,5,1)
ch <- c("I","have","fun")
F <- factor(c("A","B","C"))
cbind.colnames(c("F","ch","x","F"),d)
# E w F ch x F
# 1 D 11 A I 2 A
# 2 at 22 B have 5 B
# 3 a 33 C fun 1 C
cbind.colnames(c("x","F","ch","x"))
data.frame(x,F,ch,x) # the same
cbind.colnames(NULL) # NULL