Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR R

collapse text by group in dataframe r

# You want to aggregate text by group
df <- read.table(header=T, text="
group text
a a1
a a2
a a3
b b1
b b2
c c1
c c2
c c3
")

aggregate(df$text, list(df$group), paste, collapse="")
##   Group.1      x
## 1       a a1a2a3
## 2       b   b1b2
## 3       c c1c2c3
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #collapse #text #group #dataframe
ADD COMMENT
Topic
Name
2+6 =