I have a database like this:
Individual Year ID
A 1 R
A 1 S
A 1 T
A 2 T
B 1 T
B 5 T
C 7 S
D 9 K
D 8 H
E 1 S
There are thousands of individuals in the database.
Each individual is associated with none, one or more than one ID per year (eg. individual A has 3 different ID's for year 1, and individual D only one ID for year 10 and no other information)
I am trying to study the evolution of ID "S" throughout the years and plot a line graph in which:
x axis contain years
y axis percentage (#ID S/ # total yearly ID's for all individuals)
In this example my output should be:
Year Percentage of S
1 0,5
2 0
5 0
7 1
8 0
9 0
The value for year one is obtained by dividing 3 (total ID S in year 1) by 6 (total IDs registered for year 1).
Thanks