take: Take Elements From a Vector

Description Usage Arguments Value Examples

Description

Take elements from a vector. Useful for extracting an index from branches in a parse tree, particularly, in a magrittr chain.

Usage

1
take(x, indices = 1)

Arguments

x

A vector of elements to select from.

indices

The indices to select.

Value

Returns a subset of the original set of elements.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
take(list(1:4, LETTERS, rnorm(10)))
take(list(1:4, LETTERS, rnorm(10)), 2)
take(list(1:4, LETTERS, rnorm(10)), 1:3)

## Not run: 
## Parse example
txt <- c(
    "Really, I like chocolate because it is good. It smells great.",
    "Robots are rather evil and most are devoid of decency.",
    "He is my friend.",
    "Clifford the big red dog ate my lunch.",
    "Professor Johns can not teach",
    "",
    NA
)

if(!exists('parse_ann')) {
    parse_ann <- parse_annotator()
}
(x <- parser(txt, parse_ann))

get_phrase_type(x, "NP") %>%
    take() %>%
    get_leaves()

## End(Not run)

trinker/parsent documentation built on May 31, 2019, 9:41 p.m.