Skip to contents

Match inside nested elements

Usage

matchNested(x, table, ...)

# S4 method for character,DFrame
matchNested(x, table)

# S4 method for character,data.frame
matchNested(x, table)

# S4 method for character,list
matchNested(x, table)

Arguments

x

The values to be matched.

table

The values to be matched against. Applies across rows for DataFrame method.

...

Additional arguments.

Value

integer. A positional vector corresponding to values defined in table the same size as x.

Details

Intentionally only performs exact matching. Refer to filterNested function for partial matching support with regular expressions.

Note

Updated 2023-09-21.

Examples

## list ====
x <- c("aaa", "bbb", "ccc")
table <- list(
    c("a", "aa", "aaa"),
    list(c("b", "bb", "bbb")),
    list(list(c("c", "cc", "ccc")))
)
matchNested(x = x, table = table)
#> [1] 1 2 3

## data.frame ====
x <- c("aaa", "bbb", "ccc", "ddd")
table <- data.frame(
    "V1" = c("a", "aa", "aaa"),
    "V2" = I(list(
        c("b", "bb", "bbb"),
        c("c", "cc", "ccc"),
        c("d", "dd", "ddd")
    ))
)
matchNested(x = x, table = table)
#> [1] 3 1 2 3

## DFrame ====
x <- c("aaa", "bbb", "ccc", "ddd")
table <- S4Vectors::DataFrame(
    "V1" = c("a", "aa", "aaa"),
    "V2" = I(list(
        c("b", "bb", "bbb"),
        c("c", "cc", "ccc"),
        c("d", "dd", "ddd")
    ))
)
matchNested(x = x, table = table)
#> [1] 3 1 2 3