kinda_sort: Kinda sort

Description Usage Arguments Value See Also Examples

View source: R/zyy.R

Description

sort a vector but not very well. For a vector, x, n elements will be randomly selected, and their positions will remain unchanged as all other elements are sorted.

Usage

1
kinda_sort(x, n, decreasing = FALSE, indices)

Arguments

x

a vector

n

number of elements of x to remove from sorting (the default is approximately 10% of x), ignored if indices is given

decreasing

logical; if FALSE (default), x is sorted in increasing order

indices

a vector of indices specifying which elemnts of x should not be sorted

Value

x sorted approximately (length(x) - n)/length(x)*100 percent.

See Also

kinda_sort

Examples

1
2
3
4
5
6
7
8
9
set.seed(1)
(x <- sample(1:10))
# [1]  3  4  5  7  2  8  9  6 10  1

kinda_sort(x)
# [1]  1  2  5  3  4  6  7  8  9 10

kinda_sort(x, indices = 2:5)
# [1]  1  4  5  7  2  3  6  8  9 10

raredd/iplotr documentation built on March 19, 2021, 12:45 a.m.