random_shift: Random shift

Description Usage Arguments Details Value Examples

View source: R/random_shift.R

Description

Random shift

Usage

1
random_shift(x, position, seed, elements)

Arguments

x

string or matrix.

position

positions of elements to be replaced.

seed

seed state.

elements

vector corresponding to the alphabet from which the replacement elements are taken from.

Details

This function replaces one or more bits of a given string or rows of a given matrix with pseudorandom elements from an alphabet. If the alphabet is not specified in advance, the default binary alphabet, consisting of "0" and "1", will be used.

Value

A string or matrix with pseudorandomly generated replacements of symbols or rows.

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
# For a string
x <- "hola amigo"
random_shift(x, c(2,4,6,8), 157)
# For a matrix
A <- matrix(seq(1:100), nrow = 10, ncol = 10, byrow = TRUE)
random_shift(A, c(1, 3), 56)

## End(Not run)

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