I have the following chunk of code:
gap <- 1000
HCE <- HCE %>%
dplyr::mutate(ordered = gap * (as.numeric(outcome) - 1) + original)
I want to dismbiguate, in the mutate directive, that gap refers to the variable, not to a "gap" column. How can I do so?
The .data
and .env
pronouns make it explicit where to find objects when programming with data-masked functions.
HCE %>%
mutate(ordered = .env$gap * (as.numeric(outcome) - 1) + original)
Or use the injection operator !!
:
HCE %>%
mutate(ordered = !!gap * (as.numeric(outcome) - 1) + original)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.