I would like to replace strings with the number of times that a B
character is repeated in the string.
This is the representative input df
:
df <- c("AA", "AB", "BB", "BBB", "D", "ABB")
My expected out
output would be like that:
out <- c("0", "1", "2", "3", "0", "2")
Any idea? Thank you!