Assuming your data is in data.frame named Data , a combination of strsplit and sapply does a short job.
Data$C <- sapply(strsplit(Data$B, ";"), length)
strsplit vectorized, so it splits each element of the Data$B column into ";" and returns a list of vectors. The list has one element for each row in Data , and each element of the list contains a vector (for example, "100;2;30;5" converted to c("100","2","30","5") ). The sapply call returns the length of each vector in the list.
source share