Learn R Programming

do (version 2.0.0.1)

select: Subset data Take subset data for

Description

Subset data Take subset data for

Usage

select(data, i, ...)

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

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

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

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

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

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

Value

selected data

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

Examples

Run this code
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)

Run the code above in your browser using DataLab