elrepos: Move the position of an element in a vector.

Description Usage Arguments Details Value Note Author(s) See Also Examples

Description

Move the position of an element in a vector.

Usage

1
elrepos(x,i1,i2)

Arguments

x

A vector of unique values.

i1,i2

The position (i1) in the vector of an element that should be ahead of the element in position i2.

Details

elrepos saves the element in position i1 of the vector x and removes that element from x. It then inserts the element that was in position i1 just before the element in position i2.

Value

The vector x with the position of one element changed as above.

Note

Currently this function is only useful to perform the position changing for the function spsort.

Author(s)

Jim Lemon

See Also

spsort

Examples

1
2
3
4
 x<-unlist(strsplit("lemon",""))
 y<-elrepos(x,3,1)
 z<-elrepos(y,2,1)
 paste0(z,collapse="")

crank documentation built on May 1, 2019, 9:39 p.m.

Related to elrepos in crank...