from_to: Starting and ending positions

Description Usage Arguments Value Author(s) See Also Examples

View source: R/from_to.r

Description

Get the starting position 'from' and the ending position 'to' of the elements contained in a vector (or a list of vectors)

Usage

1
  from_to(x, ...)

Arguments

x

a numeric vector or a list of vectors

...

further arguments are ignored

Value

A list with two vectors: '$from' and '$to'. '$from' contains the indices with starting positions. '$to' contains the indices with ending positions.

Author(s)

Gaston Sanchez

See Also

lengths, listsize

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# let's say you have a numeric vector like this
num_vec = c(2, 3, 1, 4)

# get 'from' and 'to' indices
start_end = from_to(num_vec)
from = start_end$from
to = start_end$to

#' let's say you have a list like this
str_list = list(c("a","b","c"), c("d", "e"), c("f","g","h"))

# get 'from' and 'to' indices
start_end = from_to(str_list)
from = start_end$from
to = start_end$to

turner documentation built on May 2, 2019, 8:35 a.m.