fccu_as_evil: Black Magic Add/Subtract for Lists

Description Usage Arguments Value Examples

View source: R/fc_common_utils.R

Description

This is probably dangerous. Combines the objects in my_list according to my_op_str. See example.

Usage

1
fccu_as_evil(my_op_str, my_list, max_idx = length(my_list))

Arguments

my_op_str

A string representation of the arithmetic operator you want to use, "+" or "-".

my_list

The list you want to perform this sorcery on.

max_idx

The highest index you want to go to. Defaults to length(my_list).

Value

The result of the mungo addition or subtraction.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
> data1 = data.frame(a=c(1,2,3), b=c(4,5,6))
> data2 = data.frame(a=c(9,8,7), b=c(6,5,4))
> data3 = data.frame(a=c(1,1,1), b=c(2,2,2))

> fccu_as_evil("+", list(data1, data2, data3))
   a  b
1 11 12
2 11 12
3 11 12

# evaluates to the equivalent of writing out:
> data1 + data2 + data3

kmorrisongr/fcan documentation built on Sept. 9, 2020, 10:12 a.m.