matchNested: Match inside nested elements

matchNestedR Documentation

Match inside nested elements

Description

Match inside nested elements

Usage

matchNested(x, table, ...)

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

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

## S4 method for signature '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.

Details

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

Value

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

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)

## 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)

## 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)

acidgenomics/AcidBase documentation built on Jan. 28, 2024, 2:59 a.m.