Last active
May 9, 2017 16:03
-
-
Save ryanpraski/9af765e827196d91e3d3e715a3ae9c7d to your computer and use it in GitHub Desktop.
How many unique visitor viewed two or more of a group of pages (in this case shoes or socks pages). Used Adobe Analytics data warehouse to export Visitor_ID, Pages, and Page Views then got a count of visitor ids that viewed two or more of pages that contained shoes or socks in the page name. This count of visitor ids is the number of unique visi…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
df <- read.csv("C:/Users/praskry/Desktop/more_than_1.csv", header = TRUE) | |
df %>% summarize(UVs = n_distinct(Visitor_ID)) #unique visitor count | |
df1 <-filter(df, grepl('shoes|socks',Pages)) #filter to only include prod pages | |
df2 <-df1 %>% group_by(Visitor_ID) %>% filter(n()>1) | |
df3<-df2 %>% group_by(Visitor_ID) %>% summarize(count=n()) | |
df3 %>% group_by(count) %>% summarize(total.count=n()) | |
ggplot(data=df3, aes(x=count)) + geom_bar(stat="count") | |
#df4 <-spread(df2,Pages,Page.Views,fill = 0) #make long data wide- pages as column vis_id row | |
## write to csv row.names=FALSE does not write row numbers to csv | |
write.csv(df3, 'C:/Users/praskry/Desktop/df3.csv', row.names = FALSE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment