loceq {lazy.tools}R Documentation

Returns the locations of the elements of the first argument whose values are equal to one of the elements in the second argument

Description

Returns the locations of the elements of the first argument whose values are equal to one of the elements in the second argument

Usage

loceq(a, b, keep = 1)

Arguments

a

vector

b

vector

keep

= 1 not to sort the result

Details

loceq( a, b, keep=0 ) is equivalent to
which( match(a,b, nomatch=0) > 0 )
or
which( a %in% b ) .

loceq(letters, c("x","cc","a")) returns c(24,1)
With keep=0, the result will be sorted according to the order of appearance in the first argument.
loceq(letters, c("x","cc","a"), 0) returns c(1,24)

If subset below contains a subset of the variable names of a data frame,
loc=loceq( colnames(dataframe), subset )
wii return the location of those variables.

It will return 0 if no match.

Value

vector consisting of the locations of the elements of the first argument whose values are equal to one of the elements in the second argument, or 0

Examples

loceq(letters, c("x","cc","a"))
loceq(letters, c("x","cc","a"), 0)
loceq(c("x","cc","a"), letters)
loceq(c("x","cc","a"), letters, 0)


[Package lazy.tools version 0.1.3 Index]