dig_sum: Sum the digits of a number

Description Usage Arguments Details Value See Also Examples

Description

Sum the digits of a number

Usage

1
dig_sum(x, return_char = FALSE)

Arguments

x

an integer

return_char

when TRUE, the result is returned as a character string. Defaults to FALSE, returning an integer.

Details

This function works by splitting the number into its component digits, and creating a call to R that sums them.

Value

the sum of all the individual digits of that integer

See Also

dig_root()

Examples

1
2
dig_sum(10)  # 1
dig_sum(123) # 6

zkamvar/digroot documentation built on May 30, 2019, 6:15 p.m.