select.matrix: Select Columns of a Matrix

Description Usage Arguments Value Examples

View source: R/Select_Matrix.R

Description

Select columns of a matrix by name, dplyr style. Defines the dplyr::select method for matrixes.

Usage

1
2
## S3 method for class 'matrix'
select(.data, ..., throwError = TRUE)

Arguments

.data

The matrix to select columns from.

...

The column names to select (can be quoted, but not necessary).

throwError

whether to throw an error if invalid columns are selected (if FALSE), only a warning will be sent) (logical scalar).

Value

A matrix of the selected columns.

Examples

1
2
3
4
5
6
7
8
9
library(dplyr)
mat <- as.matrix(mtcars)
select(mat, mpg)
select(mat, mpg, cyl)
select(mat, mpg, cyl, "disp")
select(mat, "mpg", "cyl", "disp", "am")
try(select(mat, mpg2))
try(select(mat, mpg2, throwError = TRUE))
select(mat, mpg2, throwError = FALSE)

KO112/KO documentation built on Oct. 2, 2020, 9:21 a.m.