Having a dataframe:
dframe <- structure(list(id = c(1L, 1L, 1L, 1L), name = c("Amazon", "Google",
"Google", "Yahoo"), label = c("pre", "after", "pre", "after"),
text_sth = c("other", "another one test text_sth another text",
"another text other", "another one test text_sth another text"
)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-4L))
How is it possible to keep rows which only contains in column label pre and after for every user id detect in every name. Example of expected output:
id name label text_sth
1 Google after another one test text_sth another text
1 Google pre another text other