I have a framework with columns labeled A, B, and C. I want to add new columns that are computed from existing columns AND the new columns themselves. For this, I tried to use the conversion function as follows:
Data = transform(Data, NewD = A + B, NewE = C * NewD )
But this gives an error:
Error in eval (expr, envir, enc): object 'NewD' not found
I also tried the cbind function as follows:
NewD = Data$A + Data$B, NewE = Data$C * New$D Data=cbind(Data,NewD,NewE)
But this becomes cumbersome when the number of additional columns (functions) grows.
How can I refer to NewD inside the conversion function, or is there a better way to apply several such functions. I want the data to contain columns A, B, C, NewD and NewE without having to repeatedly reference the transform function.
variables r transform
Look left
source share