How to remove the grouped rows from the original data frame and put them in new one?

Solution 1:

Here is one way that stores your 2 data frames in a list

ibrary(dplyr)
df %>% 
 group_by(Name, school) %>% 
 summarise(n = n() > 1, Age = mean(Age)) %>% 
 split(., .$n)

`summarise()` has grouped output by 'Name'. You can override using the 

$`FALSE`
# A tibble: 4 x 4
# Groups:   Name [1]
  Name  school n       Age
  <chr> <chr>  <lgl> <dbl>
1 Jon   b      FALSE    20
2 Jon   c      FALSE    25
3 Jon   x      FALSE    30
4 Jon   y      FALSE    60

$`TRUE`
# A tibble: 1 x 4
# Groups:   Name [1]
  Name  school n       Age
  <chr> <chr>  <lgl> <dbl>
1 Jon   a      TRUE   12.5