Here is a representation of my dataset
mydata<-data.frame(ID=1:3, str=c("ANN_ABL_ABL","ABL", "SLE_ANN"))
I want to calculate the number of elements in the string of each observation, in order to have a dataset like below.
ID str number_of_elements
1 1 ANN_ABL_ABL 3
2 2 ABL 1
3 3 SLE_ANN 2