help me figure out how to Merge these two date sets using R, I need to combine with the condition that the price of the car must be equal to the budget or lower from the declared budget up to 30%
UserBudget <- data.frame(user = c("Jon", "Bill", "Maria", "Ben", "Tina"),
budget = c(5000, 10000, 20000, 40000, 60000))
AutoMarket <- data.frame(
car = c("Toyota Corolla (2000)", "Ford Focus (2002)", "Hyundai Elantra (2012)",
"Kia Forte (2014)", "Mercedes-Benz c250 (2014)","BMW 320I (2016)",
"Tesla 3 (2018)", "Audi A6 (2019)", "Porsche Macan S (2019)",
"Mercedes-Benz c63 AMG (2017)", "Lexus RX 450L (2020)","BMW 740 (2020)","JAGUAR I-Place (2019)"),
price = c(2500, 5000, 9900, 9999, 18500, 20000, 37000, 41000, 50000, 54000,55000,59000,60000)
)
The ideal result looks like this:
HappyDriver <- data.frame(
user = c("Jon", "Bill","Bill", "Maria", "Maria","Ben","Tina","Tina","Tina","Tina","Tina"),
budget = c(5000,10000,10000,20000,20000,40000,60000,60000,60000,60000,60000),
car = c("Ford Focus (2002)","Hyundai Elantra (2012)", "Kia Forte (2014)","Mercedes-Benz c250 (2014)","BMW 320I (2016)","Tesla 3 (2018)",
"Porsche Macan S (2019)", "Mercedes-Benz c63 AMG (2017)", "Lexus RX 450L (2020)","BMW 740 (2020)","JAGUAR I-Place (2019)"),
price =c(5000,9900, 9999, 18500, 20000, 37000,50000, 54000,55000,59000,60000)
)