This is the code used to derive the first table in my question.
JH %>% group_by(ATT_ID, CAR=="B") %>%
summarize(count = n(), .groups = "drop")
ATT_ID | CAR == "B" | Count |
---|---|---|
ONE | FALSE | 1 |
TWO | TRUE | 1 |
THREE | TRUE | 3 |
THREE | FALSE | 5 |
FOUR | FALSE | 2 |
FIVE | TRUE | 4 |
SIX | TRUE | 8 |
SIX | FALSE | 4 |
How can I get the table above to look like:
ATT_ID | Percentage of "B" |
---|---|
ONE | 0% |
TWO | 100% |
THREE | 37.5% |
FOUR | 0% |
FIVE | 100% |
SIX | 67% |
- Notice how some ID's are seen twice so as to show the presence of both FALSE & TRUE whereas other ID's appear once to showcase the presence of only one or the other.
Thank you