Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道如何为非列表列做类似的事情。例如:
library(tidyverse) mtcars %>% mutate(first_cyl = first(cyl))
我预计对于列表列,这将起作用:
mtcars %>% group_by(gear) %>% nest(.key = "x") %>% mutate(first_x = first(x))
但会产生错误。
我想我错过了列表功能。现在,这有效:
mtcars %>% group_by(gear) %>% nest(.key = "x") %>% mutate(first_x = list(first(x)))