exchange {LHD} | R Documentation |
Exchange two random elements in a matrix
Description
exchange
returns a new matrix by switching two randomly selected elements from a user-defined matrix
Usage
exchange(X, j, type = "col")
Arguments
X |
A matrix object. In general, |
j |
A positive integer, which stands for the j^th column (or row) of |
type |
An exchange type. If |
Value
If all inputs are logical, then the output will be a new design matrix after the exchange.
Examples
#create a toy LHD with 5 rows and 3 columns
toy=rLHD(n=5,k=3);toy
#Choose the first column of toy and exchange two randomly selected elements.
try.col=exchange(X=toy,j=1,type="col")
toy;try.col
#Choose the first row of toy and exchange two randomly selected elements.
try.row=exchange(X=toy,j=1,type="row")
toy;try.row
[Package LHD version 1.3.3 Index]