I have the following dataset
A B C D1! 0! 1! 0!0! . 1! 1!
I need to print the column name to each match as follows
matches_1 matches_0A,C B,DC,D A
I'm using:
df$matches_1 <- colSums(apply(df, 1, stringr::str_count, "1!"))
to count occurences of 1! in each row, but i'm not sure how to print the column name instead of the sum