isin: Test Whether One Vector Is In Another Vector

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

Description

See the title.

Usage

1
2
3
4
5
6
7
isin(x, ...)

## Default S3 method:
isin(x, y, ordered = FALSE, ...)

## S3 method for class 'data.frame'
isin(x, ...)

Arguments

x, y

vectors.

ordered

logical.

...

further arguments to be passed to or from other methods.

Details

The function will only return TRUE if every element of y is present in the vector x, counting multiplicity. See the examples below. Of ordered = TRUE, then elements must be in the vector x in the order specified in y. Compare this to the behavior of the %in% function in the base package.

This is a generic function with a moethod for data frames, which applies isin() to each row of the data frame, with a vector as a result.

Value

Logical, or a vector of logicals.

Author(s)

G. Jay Kerns gkerns@ysu.edu.

See Also

isrep

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
x <- 1:10
y <- 3:7
z <- c(3,3,7)
isin(x,y)
isin(x,z)
isin(x, c(3,4,5), ordered = TRUE)
isin(x, c(3,5,4), ordered = TRUE)

S <- rolldie(4)
subset(S, isin(S, c(2,2,6), ordered = TRUE))

prob documentation built on May 2, 2019, 12:20 p.m.