nathaneastwood / poorman

A poor man's dependency free grammar of data manipulation
https://nathaneastwood.github.io/poorman/
Other
338 stars 15 forks source link

`relocate()` doesn't work when `.before` and `.after` are provided a variable inside a function #110

Open nathaneastwood opened 2 years ago

nathaneastwood commented 2 years ago
r$> myFun <- function(data, col, location = 1) {
      poorman::relocate(data, col, .after = location)
    }

r$> myFun(mtcars, "mpg")
Error in value[[3L]](cond) : Column location does not exist
nathaneastwood commented 2 years ago
.after <- colnames(.data)[eval(bquote(eval_select_pos(.data, .(.after))))]

should fix the issue. Need to test.

nathaneastwood commented 2 years ago
if (!missing(.after)) .after <- colnames(.data)[eval(bquote(eval_select_pos(.data, .(deparse_var(.after)))))]