I have a data set (named desktop) that contains chronologically ordered information from a web tracker that contains the URLs visited by different users in one column and the user ID in another column. With the goal of search engine analysis I'm trying to filter all the rows that contain an URL where a user submitted a search query to google which I'm able to do with the following line of code:
data_google <- dplyr::filter(desktop, grepl('\\bgoogle.com/search\\b', desktop$url, ignore.case = T))
This works fine. However, I'm interested not only in the URL that contains the search query but also the web page the user visited after submitting the query. In other words, the link from the google result page the user actually clicked on.
Is it possible to filter not only the row where an url matches the pattern but also the the row right after that one?
Any help would be appreciated, thank you