element_mutate: Mutate elements of a string

Description Usage Arguments Details Value Examples

View source: R/element_mutate.R

Description

Mutate elements of a string

Usage

1
element_mutate(x, index, mutations)

Arguments

x

character string.

index

vector containing the positions of the elements to be replaced.

mutations

vector containing the replacements.

Details

This function allows one to replace the characters of a given string at certain positions with new characters. In case the string is binary, the default replacement is just the negation of the bits at each desired locations.

Value

A character string with changes specified by the user at desired positions.

Examples

1
2
3
4
5
6
7
## Not run: 
# For a binary string
element_mutate("1001", c(1,2,3,4))
# For a non-binary string:
element_mutate("abcd", c(1,2), c("b","a"))

## End(Not run)

allgebrist/algodyn documentation built on Oct. 21, 2019, 2:47 a.m.