I was looking for the quite basic numeric function digit sum in R.
What I do for finding the sum of digits in R :
x = readline("Enter the number") a = as.integer(c(strsplit(x,split="")[[1]])) print((sum(a)))