I’m trying to create 4 new variables from a dataset in R that contains a varying number of observations for each identifier (ID). I want to summarize this information into 2 flags that indicate whether an ID has an observation of type A or B and 2 counter variables containing the total number of A's and B's per ID. I’m trying to create 4 new variables from a dat