posmod: Modify Specific Elements of a Vector in Different Ways

Description Usage Arguments Examples

View source: R/posmod.R

Description

Carry out alternative arithmetic operations on different elements of a vector. Intended for use when specifying plot annotations using objects.

Usage

1
posmod(vector, positions, operations, numbers)

Arguments

vector

The vector to alter.

positions

The indices of the elements of the vector to alter.

operations

Mathematical operations to carry out (in conjunction with numbers) on the specified vector elements. Some degree of work-around may be needed (i.e. to square a number, set operations to '*' and the numbers element to the same as the vector element).

numbers

The numbers that are used at the end of the operation.

Examples

1
2
3
vector <- rep(1, times = 5)
posmod(vector = vector, positions = c(2, 4), operations = c('+', '-'), numbers = c(1, 1))
[1] 1 2 1 0 1

danjamesadams/Dantools documentation built on Aug. 24, 2019, 6:15 p.m.