Skip to content

Commit 5e2eddc

Browse files
Require dplyr 1.1.0 and remove dead code (#1568)
* require dplyr 1.1.0 fixes #1431 * remove if_else for dbply < 1.1.0 * Unconditionally use functions from dplyr now * NEWS bullet * Remove blank line --------- Co-authored-by: Davis Vaughan <[email protected]>
1 parent 8d13947 commit 5e2eddc

File tree

4 files changed

+31
-63
lines changed

4 files changed

+31
-63
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Depends:
2222
R (>= 3.6.0)
2323
Imports:
2424
cli (>= 3.4.1),
25-
dplyr (>= 1.0.10),
25+
dplyr (>= 1.1.0),
2626
glue,
2727
lifecycle (>= 1.0.3),
2828
magrittr,

NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# tidyr (development version)
22

3+
* tidyr now requires dplyr >=1.1.0 (#1568, @catalamarti).
4+
35
# tidyr 1.3.1
46

57
* `pivot_wider` now uses `.by` and `|>` syntax for the dplyr helper message to

R/complete.R

+15-36
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ complete <- function(data,
6969
UseMethod("complete")
7070
}
7171

72-
on_load({
73-
the$has_dplyr_1_1 <- packageVersion("dplyr") >= "1.0.99"
74-
})
75-
7672
#' @export
7773
complete.data.frame <- function(data,
7874
...,
@@ -84,11 +80,7 @@ complete.data.frame <- function(data,
8480
names <- names(out)
8581

8682
if (length(names) > 0L) {
87-
if (the$has_dplyr_1_1) {
88-
out <- dplyr::full_join(out, data, by = names, multiple = "all")
89-
} else {
90-
out <- dplyr::full_join(out, data, by = names)
91-
}
83+
out <- dplyr::full_join(out, data, by = names, multiple = "all")
9284
} else {
9385
# Avoid joining the 1x0 result from `expand()` with `data`.
9486
# That causes issues when `data` has zero rows.
@@ -112,34 +104,21 @@ complete.grouped_df <- function(data,
112104
...,
113105
fill = list(),
114106
explicit = TRUE) {
115-
116-
if (the$has_dplyr_1_1) {
117-
reframe <- utils::getFromNamespace("reframe", ns = "dplyr")
118-
pick <- utils::getFromNamespace("pick", ns = "dplyr")
119-
120-
out <- reframe(
121-
data,
122-
complete(
123-
data = pick(everything()),
124-
...,
125-
fill = fill,
126-
explicit = explicit
127-
)
107+
out <- dplyr::reframe(
108+
data,
109+
complete(
110+
data = dplyr::pick(everything()),
111+
...,
112+
fill = fill,
113+
explicit = explicit
128114
)
115+
)
129116

130-
drop <- dplyr::group_by_drop_default(data)
131-
dplyr::group_by(out, !!!dplyr::groups(data), .drop = drop)
132-
} else {
133-
dplyr::summarise(
134-
data,
135-
complete(
136-
data = dplyr::cur_data(),
137-
...,
138-
fill = fill,
139-
explicit = explicit
140-
),
141-
.groups = "keep"
142-
)
117+
drop <- dplyr::group_by_drop_default(data)
143118

144-
}
119+
dplyr::group_by(
120+
out,
121+
!!!dplyr::groups(data),
122+
.drop = drop
123+
)
145124
}

R/expand.R

+13-26
Original file line numberDiff line numberDiff line change
@@ -101,35 +101,22 @@ expand.data.frame <- function(data, ..., .name_repair = "check_unique") {
101101

102102
#' @export
103103
expand.grouped_df <- function(data, ..., .name_repair = "check_unique") {
104-
105-
if (the$has_dplyr_1_1) {
106-
reframe <- utils::getFromNamespace("reframe", ns = "dplyr")
107-
pick <- utils::getFromNamespace("pick", ns = "dplyr")
108-
109-
out <- reframe(
110-
data,
111-
expand(
112-
data = pick(everything()),
113-
...,
114-
.name_repair = .name_repair
115-
)
116-
)
117-
118-
drop <- dplyr::group_by_drop_default(data)
119-
dplyr::group_by(out, !!!dplyr::groups(data), .drop = drop)
120-
} else {
121-
dplyr::summarise(
122-
data,
123-
expand(
124-
data = dplyr::cur_data(),
125-
...,
126-
.name_repair = .name_repair
127-
),
128-
.groups = "keep"
104+
out <- dplyr::reframe(
105+
data,
106+
expand(
107+
data = dplyr::pick(everything()),
108+
...,
109+
.name_repair = .name_repair
129110
)
111+
)
130112

131-
}
113+
drop <- dplyr::group_by_drop_default(data)
132114

115+
dplyr::group_by(
116+
out,
117+
!!!dplyr::groups(data),
118+
.drop = drop
119+
)
133120
}
134121

135122
# Nesting & crossing ------------------------------------------------------

0 commit comments

Comments
 (0)