Creating data frames
Summary
21. Counteroffer savings

Instruction

Great! Let's create a new column!

Exercise

Create a new column lower_by that will contain the amount a client saved regarding the original offer. Consider only the offers that were accepted. Otherwise a value should be 0.

Stuck? Here's a hint!

First, you should create the lower_by column and set it to 0. Then you need to change the values for rows that meet the condition (i.e. that were accepted):

counteroffers[counteroffers$accepted == "Y",] <- ... 

Then you should subtract the offer column from the orig_offer column. Again, you should take into considerations only the offer column and the orig_offer column for the rows where the offer was accepted:

counteroffers[counteroffers$accepted == "Y",] <- counteroffers[counteroffers$accepted == "Y",]$orig_offer - ...