slice_range: Select a range of records from an object

Description Usage Arguments Examples

View source: R/slice_range.R

Description

Select a range of records from an object

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
slice_range(x, range, begin = range[1], end = range[2], ...)

## S3 method for class 'lvec'
slice_range(x, range, begin = range[1], end = range[2], as_r = FALSE, ...)

## S3 method for class 'ldat'
slice_range(x, range, begin = range[1], end = range[2], as_r = FALSE, ...)

## Default S3 method:
slice_range(x, range, begin = range[1], end = range[2], ...)

## S3 method for class 'data.frame'
slice_range(x, range, begin = range[1], end = range[2], ...)

Arguments

x

the object to select items from

range

a numeric vector with two elements specifying the range to select.

begin

the first element to select.

end

the last element to select.

...

ignored; used to pass additional arguments to other methods.

as_r

convert the result to an R-object.

Examples

1
2
3
4
5
6
7
8
9
x <- as_lvec(1:20)
# Select elements 5:7
slice_range(x, range = c(5, 7))
slice_range(x, begin = 5, end = 7)
slice_range(x, range = c(5, 10), end = 7)
# also works for R-vectors
slice_range(1:20, range = c(5,7))
# convert lvec to rvec
slice_range(x, range = c(5,7), as_r = TRUE)

ldat documentation built on March 26, 2020, 7:59 p.m.

Related to slice_range in ldat...