collapse text by group in dataframe r
# Assuming you have a dataframe named 'df' with columns 'group' and 'text'
# Load required library
library(dplyr)
# Group by 'group' and collapse 'text' within each group using paste function
df_collapsed <- df %>%
group_by(group) %>%
summarise(collapsed_text = paste(text, collapse = " "))
# View the resulting dataframe
print(df_collapsed)