I am working with the R programming language.
I found this link which has historical population pyramids for Canada: https://www12.statcan.gc.ca/census-recensement/2021/dp-pd/dv-vd/pyramid/index-en.htm
My Question: For every year in the drop down scroll menu (i.e. 1851 – 2043), I want to get the age-gender breakdowns. This would look something like this:
year gender age percent_of_population
1 1975 Male 25 3%
2 1975 Female 25 2%
3 1975 Male 26 1%
4 1975 Female 26 2%
5 .... .... ... ...
6 1976 Male 25 4%
7 1976 Female 25 3%
8 1976 Male 26 2%
9 1976 Female 26 1%
10 ... ... .... ,,,
So far, I am trying to look if the website itself has some button which will allow you to directly download the age-gender breakdowns for all years… but it seems I can only look at very limited information from each year.
Apart from that, I have started to "inspect" the source code of the website – but I see no "tags" that I might be able to use to understand the structure of this website.
Can someone please show me how I can solve this problem? Maybe Selenium can be useful for this?
Thanks!
2
Answers
You can download the data here.
Javascript that renders charts and tables fetches data from API endpoints, the one with age-gender breakdowns is
rest/dataviz/HistoricPyramid.json
:Created on 2023-08-04 with reprex v2.0.2