Add columns to a data frame
add_column.RdInsert one or more columns into an existing data frame.
References
Kirill Muller, Hadley Wickham, and Romain francois (Rstudio) (2017). tibble: Simple Data Frames. R package version 1.4.2. https://CRAN.R-project.org/package=tibble. Git commit 294c3cffad38f8f9f277c848742a90984fe239e3
Examples
#----------------------------------------------------------------------------
# add_column() examples
#----------------------------------------------------------------------------
library(bkdat)
df <- data.frame(x = 1:3, y = 3:1)
add_column(df, list(z = -1:1, w = 0))
#> x y z w
#> 1 1 3 -1 0
#> 2 2 2 0 0
#> 3 3 1 1 0
if (FALSE) { # \dontrun{
# You can't overwrite existing columns
add_column(df, list(x = 4:6))
# You can't increase the number of rows
add_column(df, list(z = 1:5))
} # }