Digit sum function in R

前端 未结 4 1528
盖世英雄少女心
盖世英雄少女心 2020-12-06 17:17

I was looking for the quite basic numeric function digit sum in R.

  • I did not find a preinstalled function.
  • Even in Stackoverflow\'s extensive R libra
4条回答
  •  清歌不尽
    2020-12-06 18:10

    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)))
    

提交回复
热议问题