pull.: Pull out a single variable

Description Usage Arguments Examples

View source: R/pull.R

Description

Pull a single variable from a data.table as a vector.

Usage

1
pull.(.df, var = -1)

Arguments

.df

A data.frame or data.table

var

The column to pull from the data.table as:

  • a variable name

  • a positive integer giving the column position

  • a negative integer giving the column position counting from the right

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
test_df <- data.table(
  x = 1:3,
  y = 1:3
)

# Grab column by name
test_df %>%
  pull.(y)

# Grab column by position
test_df %>%
  pull.(1)

# Defaults to last column
test_df %>%
  pull.()

mtfairbanks/gdt documentation built on May 4, 2021, 9:44 a.m.