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

How to combine specific data across multiple rows in a dataframe in R

$
0
0

I am looking to alter (concatenate, reshape I am not sure which word is right for this scenario) the data in my data frame by combining rows data cells across 1 column where the other columns in that row are identical.

Basically, I have something like this:

>df
    >Person_id     System_id    Category    Type    Tag
    >1A            134          1            Chr     Question
    >1A            134          1            Chr     Answer
    >1A            134          1            Chr     Evaluation
    >1A            134          1            Chr     Overall
    >1A            134          1            Chr     Analysis
    >Z4            002          1            Chr     Question
    >Z4            002          1            Chr     Answer

And get it to look something like this:

>Person_id     System_id    Category    Type    Tag
    >1A            134          1            Chr     Question, Answer, Evaluation, Overall, Analysis
    >Z4            002          1            Chr     Question, Answer

The Tags don't have to be separated by a comma , a space is fine. Any ideas where to look for a solution like this would be helpful.

Thank you.


Viewing all articles
Browse latest Browse all 204771

Trending Articles



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