similar {HelpersMG}R Documentation

Test if two vectors contains the same elements independently of their order

Description

Return TRUE only if all elements of x are present and only once in y.

Usage

similar(x, y, test.names = FALSE)

Arguments

x

A vector with numeric or character elements

y

A vector with numeric or character elements

test.names

Logical. If TRUE, the names of the vector elements must be also identical and unique

Value

A logical TRUE or FALSE

Author(s)

Marc Girondot marc.girondot@gmail.com

Examples

## Not run: 
A <- c("A", "B", "C", "D")
B <- c("A", "B", "C", "D")
similar(A, B)
similar(B, A)
A <- c(x="A", y="B", z="C", k="D")
B <- c(x="A", y="B", z="C", l="D")
similar(B, A)
similar(A, B, test.names=TRUE)
A <- c(x="A", y="B", z="C", k="D")
B <- c(x="A", z="C", k="D", y="B")
similar(B, A)
similar(A, B, test.names=TRUE)

## End(Not run)

[Package HelpersMG version 6.1 Index]