Set the (new or existing) column(s) of a data frame.
Arguments
- .x
data frame
- ...
column assignment(s) in the form of
<columnName> = <values>
- dbg
if
TRUE
(default) the creation of new columns is reported on the screen
Examples
# Create a data frame
x <- data.frame(a = 1:5)
# Option 1: use the "$" operator
x1 <- x
x1$b <- 2:6
x1$c <- 3:7
# Option 2: use setColumns
x2 <- setColumns(x, b = 2:6, c = 3:7)
#> Provide column 'b' to data frame 'x'... ok.
#> Provide column 'c' to data frame 'x'... ok.
# The result is the same
identical(x1, x2)
#> [1] TRUE
# but the creation of columns has been reported on the console (dbg = TRUE by
# default)
## Provide column 'b' to data frame 'x'... ok.
## Provide column 'c' to data frame 'x'... ok.