I am working on a big set of customer data and trying to find average number of stores a customer visit in each month. In my data I have unique identification number for each customer and the store codes they visited. Sample of my data frame looks like below:
sitecode<-c(1000,1000,1001,1000)
productcode<-c('X','X','Y','X')
customercode<-c('A','B','A','C')
Date<-c('01/01/2016','02/01/2016','03/01/2016','04/01/2016')
data1<-data.frame(customercode,Date,productcode,sitecode)
Based on this what I would like to have is a simple table for customers A-B-C with unique number of stores they visited which is 2 for A, 1 for B and C. Can you help?