insertCol | R Documentation |
This function inserts one or more columns or rows before or after another column or row in a data frame or matrix. It is similar to cbind
except that the inserted column(s)/row(s) can be placed anywhere.
insertCol(x, into, at = NULL, before = TRUE)
insertRow(x, into, at = NULL, before = TRUE)
x |
Data frame, matrix, or vector with same number of columns or rows or elements as |
into |
Data frame or matrix into which |
at |
Character, integer, or |
before |
Logical, if |
A data frame.
insertRow()
: Insert a column or row into a data frame or matrix
merge
, cbind
, insert
x <- data.frame(y1=11:15, y2=rev(letters)[1:5])
into <- data.frame(x1=1:5, x2='valid', x3=letters[1:5], x4=LETTERS[1:5], x5='stuff')
insertCol(x, into=into, at='x3')
insertCol(x, into=into, at='x3', before=FALSE)
insertCol(x, into)
x <- data.frame(x1=1:3, x2=LETTERS[1:3])
into <- data.frame(x1=11:15, x2='valid')
row.names(into) <- letters[1:5]
insertRow(x, into=into, at='b')
insertRow(x, into=into, at='b', before=FALSE)
insertRow(x, into)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.