I want to combine the content of two cells if several conditions are true.
I have the follwoing dataframe:
df <- data.frame(page = c("a1","a1","a2","a2","a3"),
keyword = c("a,b,c", "a,b,c,d", "d,e,f","g","a"))
The conditions in pseudo code:
if some cells of column page are equal (e.g. a1 and a2 appear two times)
then combine the content of column keyword and delete duplicate content.
This means in the end I need a dataframe, which looks like this:
page | keyword
a1 | a,b,c,d
a2 | d,e,f,g
a3 | a
I already tried different approaches but didnt receive the correct result. Does anybody has an idea?
Aucun commentaire:
Enregistrer un commentaire