I am using package tm.
I have a dataframe with 2 columns, the first column is ID and the seocnd column contains text. The dataframe looks as follows.
Id Text
13456 Hi, Good morning
13457 How are you?
13456 May I know who I am speaking to?
13456 Hi, Good evening
I have used the tm package and built dtm and extracted the top 5 words for each document and it looks like:
Id Term1 Term2 Term3 Term4 Term5
13456 Hi Good morning term4 term5
13457 How are you term4 term5
13456 I Know may who to
13456 Hi Good Evening term4 term5
But the required output is:
Id Term1 Term2 Term3 Term4 Term5
13456 Hi Good I morning evening
13457 How are you term4 term5
I could not find any previous questions posted on this. Thanks in Advance.