select: Subset data Take subset data for

Description Usage Arguments Value Examples

View source: R/select.R

Description

Subset data Take subset data for

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
select(data, i, ...)

## S3 method for class 'character'
select(data, i, ...)

## S3 method for class 'numeric'
select(data, i, ...)

## S3 method for class 'logical'
select(data, i, ...)

## S3 method for class 'data.frame'
select(data, i, j, drop = FALSE, ...)

## S3 method for class 'matrix'
select(data, i, j, drop = FALSE, ...)

## S3 method for class 'list'
select(data, i, j, drop = FALSE, ...)

Arguments

data

one vector, list, dataframe or matrix

i

element position for vector or list, row number for dataframe or matrix

...

ignore

j

column number for dataframe or matrix

drop

logical, whether to drop original format, default is FALSE

Value

selected data

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
x <- c('ab','bc','d')
x |> select(!grepl('a'))
x |> select(grepl('a'))
x |> select(!grepl('a'))
x |> select(grepl('a'))

x <- mtcars
x |> select(,!grepl('m',ignore.case = TRUE))
x |> select(grepl('m',ignore.case = TRUE),grepl('m',ignore.case = TRUE))
x |> select(!grepl('m',ignore.case = TRUE),!grepl('m',ignore.case = TRUE))

x |> select(grepl('a') & grepl('m'))
x |> select(grepl('a|m'))
x |> select(am ==1)

do documentation built on Aug. 3, 2021, 5:06 p.m.