So far, we have aggregated our data by one criterion. However, there are cases where you want to group the data by more than one column. In this section, we will discuss how we can analyze and report conversion rates by more than one criterion. As an exercise, we will use the age groups that we have built in the previous section and the marital status as the two columns to group by.
Let's first look at the code:
#### 5. Conversions by Age Groups & Marital Status ####conversionsByAgeMarital <- conversionsDF %>% group_by(AgeGroup=cut(age, breaks= seq(20, 70, by = 10)), Marital=marital) %>% summarise(Count=n(), NumConversions=sum(conversion)) %>% mutate(TotalCount=sum(Count)) %>% mutate(ConversionRate=NumConversions/TotalCount) ...