Skip to contents

Returns rows/columns selected by name in an array-like object.

Usage

get_columns(x, ...)

get_rows(x, ...)

# S4 method for data.frame
get_columns(x, select = NULL, ...)

# S4 method for data.frame
get_rows(x, select = NULL, ...)

Arguments

x

An R object (should be a matrix or a data.frame).

...

Further arguments to be passed to select.

select

A function to be applied to the row/colum names (e.g. startsWith()). Must return a single integer or logical vector.

Value

An object of the same sort as x.

See also

Other data preparation tools: append(), assign(), compact(), count(), detect(), discard(), keep(), seek()

Author

N. Frerebeau

Examples

## Seek columns
seek_columns(iris, select = startsWith, prefix = "Sepal")
#> [1] 1 2

## Get columns
x <- get_columns(iris, select = startsWith, prefix = "Sepal")
head(x)
#>   Sepal.Length Sepal.Width
#> 1          5.1         3.5
#> 2          4.9         3.0
#> 3          4.7         3.2
#> 4          4.6         3.1
#> 5          5.0         3.6
#> 6          5.4         3.9