I have a data frame with several columns containing different areas by location. In another column I have a density value. I would like to know how to create a new table (ideally through a loop) with each area multiplied by the density. My data frame looks like:
X Area1 Area2 Area3 Area4 Density
A 10.1 12 20 25 0.04
B 4.2 7.3 30 35 0.05
C 5.3 9.6 10 15 0.07
D 0.2 0.3 2 3 0.01
I have seem a similar question at: Multiply many columns by a specific other column in R with data.table? but cannot figure out a way to adapt it to work for my data. Many thanks :)