sum_loop_outputs: Sum loop outputs

Description Usage Arguments Value Examples

Description

Get sum of objects returned by a loop, added to a starting object.

Usage

1
sum_loop_outputs(start_object, loop_vector, FUN, ...)

Arguments

start_object

The object to which the sum is to be added.

loop_vector

The vector to be looped over.

FUN

Function of the loop_vector values, returning the object to be added to start_object at each iteration. First argument should be loop values argument.

...

Any additional arguments to FUN.

Value

Sum of objects returned by a loop, added to starting object.

Examples

1
2
3
4
5
6
7
matrix_example <- matrix(1:6, ncol = 2)
ShadowCAT:::sum_loop_outputs(start_object = matrix(0, 2, 2), loop_vector = 1:3, 
                             FUN = function(item, matrix_example) { 
                                     matrix_example[item,] %*% t(matrix_example[item,]) }, 
                             matrix_example = matrix_example)

 

Karel-Kroeze/ShadowCAT documentation built on May 7, 2019, 12:28 p.m.