Suppose that I have a dataset that looks like this:
which suggests that units using gas or oil receive $100 and $80, respectively, and electric units do not get any rebates. Unit 2 is only getting $10 rebate because it only uses 10% gas (see "Fuel_Fraction" column) and 10% of $100 is $10.
I don't like the way that the data is formatted, so I wanna write a chunk of code that will make it look like this:
That is, the "Rebate_USD" column for the second row (first Unit 2) is changed from $10 to $0.
Please not that the example above is a very simplified version of the actual dataset I'm using. The actual dataset is more complex and has more columns and rows. Therefore, it would be great if the solution could be as "flexible" or "general" as possible, so I can modify them relatively freely to suit my needs. In other words, the codes should not be too "rigid" to the point that it can ONLY be used to solve the example above and nothing else.
Of course, detailed explanation is always welcomed since I am quite new to R and still learning, haha.
Thank you in advance!