Sometimes when you have countries (or customers) that don’t make purchases from your store for all the years. That’s not a bad thing, just part of the business.
As you can see the above, some countries have 4 bars, which means they have made at least some kind of purchases in all the 4 years of 2012, 2013, 2014, 2015.
However, you can also see that some countries don’t have any data in some years.
Now if we want to show only the countries with 4 years of data (or bars), what can we do?
We can take the following 4 steps of the data wrangling to get the job done.
- Extract Year information from Date column.
- Group By the data frame by Country column.
- Create a calculation with Mutate step to count the number of years.
- Filter the data.
I’ve written a note to demonstrate step by step of how to do this.