I have a column in a dataframe in R, where each row contains a string. However, many of these are replicated although they are all in order, so rows with the same string are grouped together. I would like to create a new column that adds a count to the string.
I am relatively new to R and have no idea where to start with this so any suggestions would be helpful. Thanks!
Example:
String
apple
apple
apple
orange
orange
banana
banana
banana
banana
banana
I would like the second column to look like:
String-n
apple-1
apple-2
apple-3
orange-1
orange-2
banana-1
banana-2
banana-3
banana-4
banana-5