| append_column | R Documentation |
Add a (Named) Vector as a Column
append_column(x, ...)
## S4 method for signature 'data.frame'
append_column(x, column, after = 0, var = ".col")
x |
A |
... |
Currently not used. |
column |
A (named) |
after |
A length-one |
var |
A |
If column is named, names will be matched to the row names of x. Only
the first match is retained, and elements of column without a match are
removed. This allows to add as a column a vector whose length is less than
the number of rows in x (NAs will be inserted).
A data.frame.
N. Frerebeau
Other data preparation tools:
append_rownames(),
assign(),
compact(),
count(),
detect(),
discard(),
get(),
keep(),
seek()
X <- data.frame(
x = 1:5,
y = 6:10,
row.names = LETTERS[1:5]
)
Y <- c(D = 44, B = 55, Z = 22)
append_column(X, Y, after = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.