I am having trouble calculating the number of TRUE and FALSE values based off specific groups. I think this is pretty basic, but essentially I have data with many IDs and IDs that have a value of either TRUE or FALSE in a column titled one_positive (this was created with mutate() and any() to assign a TRUE value if just one of several tests was listed as positive).
Now, I am trying to calculate the total number of TRUE and FALSE one_positives per unique ID in a given a month.
My end goal is a dataframe that has three columns: Lab Month, # True, # False
chla_gono %>%
mutate(positive = ifelse(labval %in% c("DETECTED", "POS", "POSITIVE", "REACTIVE", "REACTIVEMINIMAL", "REPEATEDLY REACTIVE", "RESULT: NEISSERIA GONORRHOEAE"), "TRUE", "FALSE")) %>%
group_by(labdate,lab_month, iasid) %>%
mutate(one_positive= any(positive== "TRUE")) %>%
group_by(lab_month, iasid, one_positive) %>%
count(one_positive)
When doing this code, I get a column that lists the total number of tests that each unique ID has associated during a given time frame.