Skip to contents

Subsets a data frame to only columns specified. Will not 'drop' to vector type. This is only a convenience function that replicates the standard data[, x, drop = FALSE].

Usage

select(data, x)

Arguments

data

A data frame.

x

A character, numeric, or logical vector for specified columns.

Value

data.frame

Examples

#----------------------------------------------------------------------------
# select() examples
#----------------------------------------------------------------------------
library(bkdat)

df <- data.frame(a = c(1, 2, 3), b = c(4, 5, 6))
select(df, "a")
#>   a
#> 1 1
#> 2 2
#> 3 3
select(df, 2)
#>   b
#> 1 4
#> 2 5
#> 3 6
select(df, c(TRUE, FALSE))
#>   a
#> 1 1
#> 2 2
#> 3 3