I have a dataframe with many vars, out of which, two variables are shown in the sample dataset test
in the following code:
test <- data.frame(row_numb = c(1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3),
words = c('apply','assistance','benefit','compass','medical','online','renew','meet','service','website','center','country','country','develop','highly','home','major','obtain'))
I am trying to join the words from words column, into a new dataframe fdata
and columns Dictionary
, grouped by row_numb
and separated by ,
comma using below code:
fdata <- test %>%
select(row_numb, words) %>%
group_by(row_numb) %>%
unite(Dictionary, words, sep=",")
I couldn't get the result I was expecting:
row_numb Dictionary
1 apply, assistance, benefit, compass, medical, online, renew
2 meet, service.... and so forth
Can someone help in finding the mistake that I am doing.