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.
我有一个这样的数据框(顶部),但希望底部的数据框作为输出。
之前和之后的例子:
我们可以使用split创建一个listof data.frames
split
list
data.frame
lst1 <- split(df1, df1$item) lapply(lst1, function(x) rbind(x, ...))
或与tidyverse
tidyverse
library(dplyr) library(purrr) library(tibble) df1 %>% group_split(item) %>% map_dfr(~ add_row(.x, ...))