Sum of digits in a numeric matrix per row

Viewed 129

Having a matrix like:

        [,1] [,2] [,3] [,4] [,5] [,6]
   [1,]   11   14   17   20   23   26
   [2,]   12   15   18   21   24   27
   [3,]   13   16   19   22   25   28

I want to get only the rows that have sum of digits for each row between 2 values.

Sum of digits for each row:

   [1] 30
   [2] 38
   [3] 42

so if I want to get only rows where sum of digits is between 31 and 40, then only the row 2 with value 38 must be returned.

2 Answers
Related