I want to turn a dataframe into a list of lists, as in this example:
 df <- data.frame(var1=c("A","A","A","B","B","C"),var2=seq(1,6))
 >   var1 var2
 1    A    1
 2    A    2
 3    A    3
 4    B    4
 5    B    5
 6    C    6
 split(df$var2,df$var1)
 $A
 [1] 1 2 3
 $B
 [1] 4 5
 $C
 [1] 6
However, I wonder if it is possible to do it using a %>% pipe.
I don't know how to use split in a pipe, where df is given as an input. Or maybe there's another way.
 
     
     
     
    