I was looking for the quite basic numeric function digit sum in R.
This should be better:
digitsum <- function(x) sum(floor(x / 10^(0:(nchar(x) - 1))) %% 10)