forked from pik-piam/mrtutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalcValidPopulation.R
More file actions
30 lines (22 loc) · 1007 Bytes
/
Copy pathcalcValidPopulation.R
File metadata and controls
30 lines (22 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#' calcValidPopulation
#'
#' Returns historical development of population
#'
#' @param datasource Various daasource to load population data from can be specified here. So far available: WDI (default)
#' @author Florian Humpenoeder, Jan Philipp Dietrich, Kristine Karsens
#' @importFrom magclass getRegions getSets getSets<- getNames getNames<- add_dimension
calcValidPopulation <- function(datasource="WDI") {
if(datasource=="WDI"){
out <- readSource("TutorialWDI", "SP.POP.TOTL")
} else { stop("No datasource of the given name.") }
getNames(out) <- "Population (million people)"
getSets(out,fulldim = FALSE)[3] <- "variable"
out <- add_dimension(out, dim=3.1, add="scenario", nm = "historical")
out <- add_dimension(out, dim=3.2, add="model", nm = datasource)
return(list(
x=out,
weight=NULL,
unit="million",
description=paste0("Population data. Datasource for the Past: ",
datasource)))
}