Suppose I have this dataframe, df, in R:
UserID <- c(1, 1, 1, 5, 5, 7, 7, 9, 9, 9)
PathID <- c(1,2,3,1,2,1,2,1,2,3)
Page <- c("home", "about", "services", "home", "pricing",
"pricing", "home", "about", "home", "services")
df <- data.frame(UserID, PathID, Page)
I am trying to write a code that would return the sequence (along with UserID and PathID) where the user visits the 'home' page, but not the 'about' page subsequently. My output should look like this:
UserID <- c(5, 5, 7, 7, 9, 9, 9)
PathID <- c(1,2,1,2,1,2,3)
Page <- c("home", "pricing", "pricing", "home", "about", "home", "services")
df1 <- data.frame(UserID, PathID, Page)
I would really appreciate some help here.