pull.: Pull out a single variable

View source: R/pull.R

pull.R Documentation

Pull out a single variable

Description

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

Usage

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

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

name

Optional - specifies the column to be used as names for the vector.

Examples

df <- data.table(
  x = 1:3,
  y = 1:3
)

# Grab column by name
df %>%
  pull(y)

# Grab column by position
df %>%
  pull(1)

# Defaults to last column
df %>%
  pull()

tidytable documentation built on Oct. 5, 2023, 5:07 p.m.