insert.ord: Insert a value to a vector preserving the existing order

Description Usage Arguments Details Value Author(s) Examples

View source: R/r-utility-insert-ord.R

Description

This function inserts a new value to an ordered vector with preserving the existing order. It is used in examples presented in the book Cichosz, P. (2015): Data Mining Algorithms: Explained Using R. See Appendix B or http://www.wiley.com/go/data_mining_algorithms for more details.

Usage

1
insert.ord(v, v1, decreasing = FALSE)

Arguments

v

an ordered numeric or character vector

v1

a numeric value or a character string

decreasing

a flag indicating whether v is ordered decreasingly or increasingly

Details

The new value v1 is inserted into v in such a way that the ordering of v is preserved.

Value

A copy of v with v1 inserted at the appropriate order-preserving position.

Author(s)

Pawel Cichosz <p.cichosz@elka.pw.edu.pl>

Examples

1
2
3
4
insert.ord(1:10, 3.5)
insert.ord(10:1, 3.5, decreasing=TRUE)
insert.ord(1:10, 0)
insert.ord(1:10, 11)

42n4/dmr.util documentation built on May 20, 2019, 2:02 p.m.