如何在 R 中将行与按日期分组的文本聚合在一起?

How to aggregate the rows with text grouping them by date in R?

举个例子,我有这样一个 table: enter image description here

但我想要一个像这样的 table: enter image description here

你需要这个吗? group_bysummarisetoString():

library(dplyr)
# your dataframe
Date <- c("30/05/2020", "30/05/2020", "30/05/2020",
          "29/05/2020", "29/05/2020")
Text <- c("Here we are", "He likes ABC", "She likes DEF",
          "Cat eats XYZ", "I have a pet")

df <- data.frame(Date, Text)


df %>% 
  group_by(Date) %>% 
  summarise(Text = toString(Text))

输出:

  Date       Text                                    
  <chr>      <chr>                                   
1 29/05/2020 Cat eats XYZ, I have a pet              
2 30/05/2020 Here we are, He likes ABC, She likes DEF