A set of R scripts to populate an indicator on trends in B.C.'s population size and distribution. These scripts reproduce the analysis and plots published on Environmental Reporting BC.
The source data for the indicator is publically available from BC Stats, the central statistical agency of the Province of British Columbia.
(1) The 'Annual population, July 1, 1867-2017 (CSV)' data file is downloaded directly from the BC Stats web page, distributed under the Access Only - B.C. Crown Copyright licence.
(2) The 'Sub-provincial Population Estimates 1986-2017 (CSV)' data file (Access Only - B.C. Crown Copyright licence) can be manually downloaded from the BC Stats Sub-provincial Population Estimates search tool following this manual query:
+ Select region type: Regional District
+ Select regions: select all
+ Select sex(es): Totals
+ Select age group: Totals
+ Generate output
+ Export to CSV
There are two core scripts that are required for the analysis, they need to be run in order:
01_clean.R
- cleans and prepares data for analysis02_output.R
- creates maps and graphs and saves outputs
The run_all.R
script can be source
ed to run it all at once.
Most packages used in the analysis can be installed from CRAN using install.packages()
, but you will need to install envreportutils
and patchwork
using devtools:
install.packages("devtools") # if you don't already have it installed
library(devtools)
install_github("bcgov/envreportutils")
install_github("thomasp85/patchwork")
To report bugs/issues/feature requests, please file an issue.
If you would like to contribute, please see our CONTRIBUTING guidelines.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Copyright 2016 Province of British Columbia
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This repository is maintained by Environmental Reporting BC. Click here for a complete list of our repositories on GitHub.