Repository navigation
Expand file tree
/
Copy pathpull.Rd
More file actions
49 lines (42 loc) · 1.29 KB
/
Copy pathpull.Rd
File metadata and controls
49 lines (42 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pull.R
\name{pull}
\alias{pull}
\title{Pull out a single variable}
\usage{
pull(.data, var = -1, name = NULL)
}
\arguments{
\item{.data}{A table of data}
\item{var}{A variable specified as:
\itemize{
\item a literal variable name
\item a positive integer, giving the position counting from the left
\item a negative integer, giving the position counting from the right.
}
The default returns the last column (on the assumption that's the
column you've created most recently).
This argument is taken by expression and supports
\link[rlang:quasiquotation]{quasiquotation} (you can unquote column
names and column positions).}
\item{name}{An optional parameter that specifies the column to be used
as names for a named vector. Specified in a similar manner as \code{var}.}
}
\description{
This works like \code{[[} for local data frames, and automatically collects
before indexing for remote data tables.
}
\examples{
mtcars \%>\% pull(-1)
mtcars \%>\% pull(1)
mtcars \%>\% pull(cyl)
# Also works for remote sources
if (requireNamespace("dbplyr", quietly = TRUE)) {
df <- dbplyr::memdb_frame(x = 1:10, y = 10:1, .name = "pull-ex")
df \%>\%
mutate(z = x * y) \%>\%
pull()
}
# Pull a named vector
starwars \%>\% pull(height, name)
}