hi I want to to ensure this code I made below is correct. I have my data. I want to group by "id" and "year" summarize and make a new column in which I take the value of the categorical variable "cat" within the grouping WHERE I see the max value of the variable "age". if there is two "cats" with the same age, take the earliest one by arranging id and year.
is the below code correct in achieving my desired goal?
A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here.