I have 5 columns, Units1, Units2, Units3, Units4, Units5. I am trying to create a new column say
master$Sales <- master$Units1
However, I want this Units1 to be dynamic such that Sales has the datatype of UnitsX.
My current solution created Sales as a list instead of double.
Sales_Variable <- "Units"
UnitsType <- x #which is 1 in this case
master$Sales <- master[names(master) == paste0(Sales_Variable,UnitsType)]
Please guide me on how I can solve this.
Thanks,
Ashutosh Deshpande