I have 6 ratings that i have to multiply by their respective weights (it's a nasa tlx) to obtain a weighted rating for each domain, like this:
6 ratings r_mental, r_physical, r_temporal, r_effort, r_performance, r_frustration
6 weights: w_mental, w_physical, w_temporal, w_effort, w_performance, w_frustration
and i have to multiply each r_xxx with each w_xxx to obtain a "weighted_xxx" column.
now, to make the new column i just do:
mutate(nasa, weighted_mental = r_mental*w_mental)
and i would probably be already done manually writing this line six times to get weighted_physical, weighted_temporal, etc. , but i'm sure there's a smarter way to do it.
how do i iterate the operation 6 times for consecutive columns? how do i make r get the name of the weighted_xxx column correctly?
The problem with what you're trying to do is that your data isn't actually tidy. You should read that, but the tl;dr version is that you shouldn't encode important information in column names. Break that data out into it's own column. Once that is done, the operation becomes incredibly easy:
Output: