I have a table with three columns: Date
, Individual
and Category
.
I do not know how many individuals there are.
I also do not know how many categories there are in total.
Here is a toy example that I manually created with two individuals and three categories:
Date Indiv Cat
3/7/2019 IndivA 1
4/7/2019 IndivA 1
5/7/2019 IndivA 1
6/7/2019 IndivA 1
7/7/2019 IndivA 2
8/7/2019 IndivA 2
9/7/2019 IndivA 3
10/7/2019 IndivA 2
11/7/2019 IndivA 2
3/7/2019 IndivB 1
4/7/2019 IndivB 1
5/7/2019 IndivB 1
6/7/2019 IndivB 2
7/7/2019 IndivB 2
8/7/2019 IndivB 3
9/7/2019 IndivB 3
10/7/2019 IndivB 3
11/7/2019 IndivB 2
Here is the expected out:
Date Cat1 Cat2 Cat3
3/7/2019 2 0 0
4/7/2019 2 0 0
5/7/2019 2 0 0
6/7/2019 1 1 0
7/7/2019 0 2 0
8/7/2019 0 1 1
9/7/2019 0 0 2
10/7/2019 0 1 1
11/7/2019 0 1 0
The number of column will vary depending on the number of category. The number of rows will vary depending on the date length.
Is there an way to transform the initial table to yield the result that I created manually please ?