let's imagine you are doing something like this:
mutate(mtcars,
ff1 = hp + wt*1,
ff2 = hp + wt*2,
ff3 = hp + wt*3,
ff4 = hp + wt*4)
In this case we have just four new columns to create and it is quite easy to do it manually. However, imagine that you want to create 150 new columns in this way. It would be very tedious and time-consuming to write out all the individual ff = stuff. It would be the easiest if we could do something like this:
mutate(mtcars,
ff = hp + wt*seq(1:150))
However, this doesn't work because of this thing:
Error in `mutate()`:
! Problem while computing `ff = hp + wt * seq(1:150)`.
ā `ff` must be size 32 or 1, not 150.
So what is the proper syntax to achieve the desired output? Thanks.