hayio
5/6/2016 - 10:53 PM

creating columns

creating columns

# create new column with value combined from other row values
totalWin[, partition := ceiling(totalWin$no/totalWin$size) ]

# new column with name in variable
# WARNING get is calculated for each group!!!
# so here this column is chosen once for all rows as there is one group (bv default)
labelChoice <- 'good'
prep[, (labelChoice) := 2 * get(labelChoice)]

# WARNING get is calculated for each group!!!
# therefore here if column under choiceOut is changing it will be sancioned
nrowDt <- nrow(dt)
dt[, out := get(paste(choice, 'Out', sep='')) - 1, by=1:nrowDt]