Learn R Programming

neighbours (version 0.1-5)

compare_vectors: Compare Vectors

Description

Compare numeric or logical vectors.

Usage

compare_vectors(..., sep = "", diff.char = "|")

Value

depends on how the function is called; typically a list

Arguments

...

vectors of the same length

sep

a string

diff.char

a single character

Author

Enrico Schumann

Details

The function compares vectors with one another. The main purpose is to print a useful representation of differences (and return differences, usually invisibly).

The function is still experimental and will likely change.

See Also

neighbourfun

Examples

Run this code
x <- runif(5) > 0.5
nb <- neighbourfun(type = "logical")

compare_vectors(x, nb(x))
## 01010
##  |
## 00010
## The vectors differ in  1  place.

nb <- neighbourfun(type = "logical", stepsize = 2)
compare_vectors(x, nb(x))
## 01010
## |   |
## 11011
## The vectors differ in  2  places.

Run the code above in your browser using DataLab