Skip to content

Commit

Permalink
fix when argument passed is NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennebacher committed Aug 27, 2022
1 parent e7ed1c6 commit 54fdb68
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions R/relocate.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,21 @@ relocate.data.frame <- function(.data, ..., .before = NULL, .after = NULL) {
col_pos <- select_positions(.data, ...)

if (!missing(.before)) {
x <- try(eval_expr(.before), silent = TRUE)
x <- try(eval(.before), silent = TRUE)
if (inherits(x, "try-error")) {
.before <- colnames(.data)[eval_select_pos(.data, substitute(.before))]
} else if (is.null(x)) {
.after <- NULL
} else {
.before <- colnames(.data)[eval_select_pos(.data, .before)]
}
}
if (!missing(.after)) {
x <- try(eval_expr(.after), silent = TRUE)
x <- try(eval(.after), silent = TRUE)
if (inherits(x, "try-error")) {
.after <- colnames(.data)[eval_select_pos(.data, substitute(.after))]
} else if (is.null(x)) {
.after <- NULL
} else {
.after <- colnames(.data)[eval_select_pos(.data, .after)]
}
Expand Down

0 comments on commit 54fdb68

Please sign in to comment.