【发布时间】:2020-11-07 09:15:00
【问题描述】:
我正在尝试更新 tibble 中反向编码项目的代码,以使用 dplyr 中的 across() 函数而不是 mutate_at()。我现在的代码如下所示:
reversed_items <- c("x1","x4","x12")
data <- data %>%
mutate_at(vars(reversed_items), function(x)6-x )
这行得通。但是,每当我尝试更新我的代码以包含 across() 函数时,我都会收到此错误:
Error: Problem with `mutate()` input `..2`.
x Input `..2` must be a vector, not a `formula` object.
ℹ Input `..2` is `~recode(6 - .x)`.
我已阅读:https://www.tidyverse.org/blog/2020/04/dplyr-1-0-0-colwise/ 但无法正常工作。
【问题讨论】: