Say I have a data table like this in R:
And I want to a add column to this table which indicates if the person switched majors (like "Y" for switched, "N" for didn't switch), how would I do that? I've tried using the count and unique functions but don't know how to proceed.