expense <- as.tibble (data_frame(date =(Sys.Date() + sort(sample(1:30, 18))),
shops = c("Brooklyn", "SunriseMart","Fairway","Westside","Hapanowicz", "Applestone", "Pyramid","BP","Speedway",
"Sunoco","LaEsquina", "Xian", "EMo","Mos","HughEsan","MVM","Budget","Uber")))
categories = as.tibble (c("Groceries","Takeout", "Petrol","Travel"))
takeout_master = as_tibble(data_frame(shops= c("LaEsquina", "Xian", "EMo","Mos","HughEsan"), categ = c("Takeout")))
Assume I have 10,000 observations in expenses which are more or less repeats of the above values. How can I group them into the categories?
For example: Brooklyn & Sunrise into Groceries, MVM & Uber into Travel, Xian & Mos into Takeout, Speedway & Sunoco in Petrol etc.
Thanks in advance
Edit: After reading FJCC's response below, I realise my query may be confusing. It is not just Xian & Mos that need to be categorised as Takeout but also LaEsquina, EMo, HughEsan and any other Takeouts that may pop up in the remaining 10,000 values under shops.
It maybe that I need another data_frame like takeout_master and then match these.
I was hoping for a cleaner, advanced and sophisticated way to do this