I have the following two tibbles:
my_stats_tbl <- tribble(
~year, ~model_id,
2011, "132",
2012, "145,167",
2013, "132,145,167",
2014, "132,174",
2015, "174,182,183",
2016, "183",
2017, "191"
)
and
model_tbl <- tribble(
~id, ~name,
132, "Race",
145, "Out",
167, "Lazer",
174, "Wow",
182, "Super",
183, "Tornado",
191, "Cloud"
)
I would like to add another column to the first one so that I can list the model names based on the values from the second tibble. This is the expected output should look like this:
my_new_stats_tbl <- tribble(
~year, ~model_id, ~model_name,
2011, "132", "Race",
2012, "145,167", "Out,Lazer",
2013, "132,145,167", "Race,Out,Lazer",
2014, "132,174", "Race,Wow",
2015, "174,182,183", "Wow,Super,Tornado",
2016, "183", "Tornado",
2017, "191", "Cloud"
)
How can I achieve that?
thanks,