Learn R Programming

tidyfst (version 0.7.7)

select_dt: Select column from data.frame

Description

Analogous function for select and select_if in dplyr.

Usage

select_dt(data, ..., cols = NULL, negate = FALSE)

select_if_dt(data, .if)

Arguments

data

data.frame

...

List of variables or name-value pairs of summary/modifications functions.

cols

(Optional)A numeric or character vector.

negate

Applicable when regular expression is used. If TRUE, return the non-matched pattern. Default uses FALSE.

.if

Conditional function to select columns. When starts with `-`(minus symbol), return the negative columns.

Value

data.table

See Also

select, select_if

Examples

Run this code
# NOT RUN {
iris %>% select_dt(Species)
iris %>% select_dt(Sepal.Length,Sepal.Width)
iris %>% select_dt(Sepal.Length:Petal.Length)
iris %>% select_dt(-Sepal.Length)
iris %>% select_dt(-Sepal.Length,-Petal.Length)
iris %>% select_dt(-(Sepal.Length:Petal.Length))
iris %>% select_dt(c("Sepal.Length","Sepal.Width"))
iris %>% select_dt(1)
iris %>% select_dt(-1)
iris %>% select_dt(1:3)
iris %>% select_dt(-(1:3))
iris %>% select_dt(1,3)
iris %>% select_dt("Pe")
iris %>% select_dt("Pe",negate = TRUE)
iris %>% select_dt("Pe|Sp")
iris %>% select_dt(cols = 2:3)
iris %>% select_dt(cols = names(iris)[2:3])

iris %>% select_if_dt(is.factor)
iris %>% select_if_dt(-is.factor)
# }

Run the code above in your browser using DataLab