Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Create a column grouping strings text extracted from a column based on another column in R

$
0
0

this is my dataset

id   text
 1    "red"
 1    "blue"
 2    "light blue"
 2    "red"
 2    "yellow"
 3    "dark green"

this is the result I want to obtain:

 id  text2
 1   "red, blue"
 2  "light blue, red, yellow"
 3  "dark green"

basically I need to put together the text from column 'text' with commas to separate the different elements


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>