-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmutate-joins.Rd
181 lines (157 loc) · 4.38 KB
/
mutate-joins.Rd
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tidyverse.R
\name{mutate-joins}
\alias{mutate-joins}
\alias{inner_join.ir}
\alias{left_join.ir}
\alias{right_join.ir}
\alias{full_join.ir}
\title{Mutating joins for an \code{ir} object}
\source{
\code{\link[dplyr:mutate-joins]{mutate-joins}}
}
\usage{
inner_join.ir(
x,
y,
by = NULL,
copy = FALSE,
suffix = c(".x", ".y"),
...,
keep = FALSE,
na_matches = c("na", "never")
)
left_join.ir(
x,
y,
by = NULL,
copy = FALSE,
suffix = c(".x", ".y"),
...,
keep = FALSE,
na_matches = c("na", "never")
)
right_join.ir(
x,
y,
by = NULL,
copy = FALSE,
suffix = c(".x", ".y"),
...,
keep = FALSE,
na_matches = c("na", "never")
)
full_join.ir(
x,
y,
by = NULL,
copy = FALSE,
suffix = c(".x", ".y"),
...,
keep = FALSE,
na_matches = c("na", "never")
)
}
\arguments{
\item{x}{An object of class \code{ir}.}
\item{y}{A data frame.}
\item{by}{A character vector of variables to join by.
If \code{NULL}, the default, \verb{*_join()} will perform a natural join, using all
variables in common across \code{x} and \code{y}. A message lists the variables so that you
can check they're correct; suppress the message by supplying \code{by} explicitly.
To join by different variables on \code{x} and \code{y}, use a named vector.
For example, \code{by = c("a" = "b")} will match \code{x$a} to \code{y$b}.
To join by multiple variables, use a vector with length > 1.
For example, \code{by = c("a", "b")} will match \code{x$a} to \code{y$a} and \code{x$b} to
\code{y$b}. Use a named vector to match different variables in \code{x} and \code{y}.
For example, \code{by = c("a" = "b", "c" = "d")} will match \code{x$a} to \code{y$b} and
\code{x$c} to \code{y$d}.
To perform a cross-join, generating all combinations of \code{x} and \code{y},
use \code{by = character()}.}
\item{copy}{If \code{x} and \code{y} are not from the same data source,
and \code{copy} is \code{TRUE}, then \code{y} will be copied into the
same src as \code{x}. This allows you to join tables across srcs, but
it is a potentially expensive operation so you must opt into it.}
\item{suffix}{If there are non-joined duplicate variables in \code{x} and
\code{y}, these suffixes will be added to the output to disambiguate them.
Should be a character vector of length 2.}
\item{...}{Other parameters passed onto methods.}
\item{keep}{Should the join keys from both \code{x} and \code{y} be preserved in the
output?}
\item{na_matches}{Should \code{NA} and \code{NaN} values match one another?
The default, \code{"na"}, treats two \code{NA} or \code{NaN} values as equal, like
\code{\%in\%}, \code{\link[=match]{match()}}, \code{\link[=merge]{merge()}}.
Use \code{"never"} to always treat two \code{NA} or \code{NaN} values as different, like
joins for database sources, similarly to \code{merge(incomparables = FALSE)}.}
}
\value{
\code{x} and \code{y} joined. If the \code{spectra} column is renamed, the \code{ir}
class is dropped. See \code{\link[dplyr:mutate-joins]{mutate-joins}}.
}
\description{
Mutating joins for an \code{ir} object
}
\examples{
## inner_join
set.seed(234)
dplyr::inner_join(
ir_sample_data,
tibble::tibble(
id_measurement = c(1:5, 101:105),
nitrogen_content = rbeta(n = 10, 0.2, 0.1)
),
by = "id_measurement"
)
## left_join
set.seed(234)
dplyr::left_join(
ir_sample_data,
tibble::tibble(
id_measurement = c(1:5, 101:105),
nitrogen_content = rbeta(n = 10, 0.2, 0.1)
),
by = "id_measurement"
)
## right_join
set.seed(234)
dplyr::right_join(
ir_sample_data,
tibble::tibble(
id_measurement = c(1:5, 101:105),
nitrogen_content = rbeta(n = 10, 0.2, 0.1)
),
by = "id_measurement"
)
## full_join
set.seed(234)
dplyr::full_join(
ir_sample_data,
tibble::tibble(
id_measurement = c(1:5, 101:105),
nitrogen_content = rbeta(n = 10, 0.2, 0.1)
),
by = "id_measurement"
)
}
\seealso{
Other tidyverse:
\code{\link{arrange.ir}()},
\code{\link{distinct.ir}()},
\code{\link{extract.ir}()},
\code{\link{filter-joins}},
\code{\link{filter.ir}()},
\code{\link{group_by}},
\code{\link{mutate}},
\code{\link{nest}},
\code{\link{pivot_longer.ir}()},
\code{\link{pivot_wider.ir}()},
\code{\link{rename}},
\code{\link{rowwise.ir}()},
\code{\link{select.ir}()},
\code{\link{separate.ir}()},
\code{\link{separate_rows.ir}()},
\code{\link{slice}},
\code{\link{summarize}},
\code{\link{unite.ir}()}
}
\concept{tidyverse}