我正在尝试更新 tibble 中反向编码项目的代码,以使用across()dplyr 中的函数而不是mutate_at(). 我现在的代码如下所示:
reversed_items <- c("x1","x4","x12") \n\ndata <- data %>% \n mutate_at(vars(reversed_items), function(x)6-x )\nRun Code Online (Sandbox Code Playgroud)\n这有效。但是,每当我尝试更新代码以包含该across()函数时,我都会收到此错误:
Error: Problem with `mutate()` input `..2`.\nx Input `..2` must be a vector, not a `formula` object.\n\xe2\x84\xb9 Input `..2` is `~recode(6 - .x)`.\nRun Code Online (Sandbox Code Playgroud)\n我读过: https: //www.tidyverse.org/blog/2020/04/dplyr-1-0-0-colwise/但无法让它工作。
\n