select: Subset data Take subset data for

View source: R/select.R

selectR Documentation

Subset data Take subset data for

Description

Subset data Take subset data for

Usage

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

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 Sept. 12, 2024, 6:27 a.m.