FUN
must be a binary function that also accepts a single argument.
The result is a list with first element FUN(a[[1]])
.
For i >= 2
, elements are FUN(a[[i]], out[[i-1]])
,
where out
is the result list.
cumapply_byname(FUN, a)
FUN | the function to be applied |
---|---|
a | the list of matrices or numbers to which |
a list of same length as a
containing the cumulative application of FUN
to a
naryapply_byname()
and cumapply_byname()
are similar.
Their differences can be described by considering a data frame.
naryapply_byname()
applies FUN
to several columns (variables) of the data frame.
For example, sum_byname()
applied to several variables gives another column
containing the sums across each row of the data frame.
cumapply_byname()
applies FUN
to successive entries in a single column.
For example sum_byname()
applied to a single column gives the sum of all numbers in that column.
#> [[1]] #> [1] 1 #> #> [[2]] #> [1] 3 #> #> [[3]] #> [1] 6 #> #> [[4]] #> [1] 10 #>#> [[1]] #> [1] 1 #> #> [[2]] #> [1] 3 #> #> [[3]] #> [1] 6 #> #> [[4]] #> [1] 10 #>#> [[1]] #> [1] 1 #> #> [[2]] #> [1] 2 #> #> [[3]] #> [1] 6 #> #> [[4]] #> [1] 24 #>#> [[1]] #> [1] 1 #> #> [[2]] #> [1] 2 #> #> [[3]] #> [1] 6 #> #> [[4]] #> [1] 24 #>