how do i paste rows on the basis of another column in r?

Does this work:

> library(dplyr)
> library(tidyr)
> df %>% separate(col = ID, into = c('ID','Sub-ID'), sep = '\\.') %>% group_by(ID) %>% summarise(Text = paste0(Text, collapse = ' '))
`summarise()` ungrouping output (override with `.groups` argument)
# A tibble: 2 x 2
  ID     Text                                    
  <chr>  <chr>                                   
1 Text 1 Hello Hello World World Ciao            
2 Text 2 Ciao Ciao SO will fix it World  is great
> 

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top