I've been struggling with this problem for a week and I'm unable to form the logic for this one:
I have this Sort of migration table ( or pivot table):
Region County1 County2 County 3... County 75 Multiplier
County1 0.23 0.56 0.54 ... 0.75 1200
County2 0.54 0.33 0.66 ... 0.66 1321
...
County75 0.92 0.21 0.12 ... 0.45 1600
I want to multiply the first row element of the Multiplier to the first County column (for example: 1200*(County1))
I was trying to automate something like this:
Table1$County1 <- Table1$Multiplier[1] * Table1$County1
I've been trying to think of either using loops/functions, dplyr, etc. but I'm unable to come up with a working code/my logic is severely flawed. Any help/advice is welcome, I've been scouring through Stack Overflow but I don't know what exactly to search for (or what this operation is called). I don't mean to cause any duplication if a similar solution already exists, and if it does I have been unable to find it :(.
(In excel this would be similar to using $ (dollar sign) with the column name and multiplying)
The output should look something like this:
Region County1 County2 ... County 75 Multiplier
County1 276 739.76 ... 1200 1200
County2 648 435.93 ... 1056 1321
...
County75 1104 277.41... 720 1600
Thank you!