I have two datasets ("regular_season" and "championships") and I'm trying to see how the players in the championship round performed during the regular season. To do this, I am trying to isolate the subset of those championship round players by looking at their "id" in the regular season dataset (in the regular season dataset, it is termed "user_id," but the actual id numbers are the same) by doing the following:
champ_in_rs <- setdiff(regular_season$user_id, championships$id)
champ_in_rs <- setdiff(regular_season$user_id, champ_in_rs)
id_champ_in_rs <- numeric(length(champ_in_rs))
champ_in_rs <- subset(regular_season, user_id %in% id_champ_in_rs )
This crashed my R a few times and then it returned an empty dataset. Could someone show me how to better write this code?
EDIT: The dataset I'm working with is much larger but as an example, if the regular_season dataset has values
1,4,6,10,15,35
and the championship dataset has values
6, 35
I'm hoping to try to figure out a way to take a subset of the regular_season dataset that includes only 6 and 35.