I'm doing a group_by + summarize() operation on a large dataframe for a lot of groups and across a lot of rows. On the aggregated dataset (each line a group), I would like to concatenate all the row entries in one string per line.
library(dplyr)
df <- tribble(
  ~country, ~var,     
  "France", "Apple",  
  "France", "Pear",   
  "France", "Orange", 
  "France", "Apple",  
  "USA", "Pear",   
  "USA", "Pear",   
  "USA", "Orange" 
)
The output that should result is:
df_summarized <- tribble(
   ~country, ~summary,
  "France", "Apple, Pear, Orange, Apple", 
  "USA", "Pear, Pear, Orange"
)
