insertColumns | R Documentation |
Insert one or more new columns into a data frame before or after the given column
insertColumns(
Data,
...,
before = "",
after = "",
stringsAsFactors = defaultIfNULL(options()$stringsAsFactors, FALSE)
)
Data |
data frame |
... |
named objects each of which will be a new column in the data frame. Each object must have as many elements as Data has rows. |
before |
name of column before which to insert the new column(s) |
after |
name of column after which to insert the new column(s) |
stringsAsFactors |
passed on to data.frame() and cbind() |
data frame Data
with new columns inserted before the column
named as given in before
or after the column named as given in
after
Data <- data.frame(A = 1:5, B = 2:6)
# Insert new columns X and Y before column "B"
insertColumns(Data, before = "B", X = paste0("x", 1:5), Y = paste0("y", 1:5))
# This is the same as inserting new columns X and Y after column "A":
insertColumns(Data, after = "A", X = paste0("x", 1:5), Y = paste0("y", 1:5))
# You may also insert before the first...
insertColumns(Data, before = "A", X = paste0("x", 1:5), Y = paste0("y", 1:5))
# ... or after the last column
insertColumns(Data, after = "B", X = paste0("x", 1:5), Y = paste0("y", 1:5))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.