op_formula {formulops}R Documentation

Perform a mathematical operation on two formula

Description

Perform a mathematical operation on two formula

Usage

op_formula(op, e1, e2)

multiply_formula(e1, e2)

divide_formula(e1, e2)

add_formula(e1, e2)

subtract_formula(e1, e2)

## S3 method for class 'formula'
Ops(e1, e2)

## S3 method for class 'formula'
Math(x, ...)

Arguments

op

The operation to perform either as a name or something that can be coerced into a name.

e1, e2, x

The formulae to operate on

...

Ignored.

Details

The method for combination depends if the two formula are one- or two-sided.

If both formula are one-sided, the right hand side (RHS) of both are added together with additional parentheses added, if parentheses appear to be needed. If both formula are two-sided, the left hand side (LHS) and RHS are separately added. If one formula is one-sided and the other is two-sided, the LHS is selected from the two-sided formula and the RHS follows rules as though two one-sided formula were added.

multiply_formula Multiply two formula (identical to (a~b) * (c~d)

divide_formula Divide two formula (identical to (a~b) / (c~d)

add_formula Add two formula (identical to (a~b) + (c~d)

subtract_formula Multiply two formula (identical to (a~b) - (c~d)

Ops.formula Supports generic binary operators and a couple of unary operators (see ?Ops).

Math.formula Supports generic unary operators (see ?Math).

Value

e1 and e2 combined by the operation with the environment from e1. See Details.

Examples

op_formula("+", a~b, c~d)
op_formula("+", a~b, ~d)
op_formula("+", ~b, c~d)
op_formula("+", ~b, ~d)
op_formula("-", a~b)
op_formula("-", -a~b) # Dumb, but accurate
op_formula("-", -a~b, c~-d) # Dumb, but accurate

log(a~b)

[Package formulops version 0.5.0 Index]