Population of Europe by Country

From Opasnet
Revision as of 11:59, 4 November 2010 by Teemu R (talk | contribs) (→‎Data)
Jump to navigation Jump to search


Scope

Indices

  • Country
  • Year
    • 2010, 2020, 2030, 2050
  • Sex
  • Age
  • Growth rate
    • high, medium, low

Definition

Data

Constructed from data in Population of Europe, by summing results for each country using the R code below. The code requires database functions described here.

locs <- op_baseGetLocs("opasnet_base", "Op_en3017")
countries <- locs[grep("CountryID", locs$ind),3]
i <- 1
data <- op_baseGetData("opasnet_base", "Op_en3017", include = countries[i])
data <- data[order(data[,3], data[,4], data[,7], data[,8], data[,9]),]
n <- data[gsub(" ", "", data[,"Age"])=="0-4",]
n <- n[gsub(" ", "", n[,"Rate"])=="h",]
n <- n[gsub(" ", "", n[,"Sex"])=="Female",]
n <- n[gsub(" ", "", n[,"Year"])=="2010",]
n <- nrow(n)
data2 <- data[1:(nrow(data)/n),c("Age","CountryID","Rate","Sex","Year","Result")]
for (j in 1:(nrow(data)/n)) {
	data2[j,] <- data.frame(data[j*n-n+1,c("Age","CountryID","Rate","Sex","Year")], sum(data[(j*n-n+1):(j*n),"Result"]))
}
op_baseWrite("opasnet_base", data2, ident = "Op_en4691", name = "Population of Europe by country", unit = "#", objtype_id = 1, 
who = "Teemu R", acttype = 4)
for (i in 2:length(countries)) {
	data <- op_baseGetData("opasnet_base", "Op_en3017", include = countries[i])
	data <- data[order(data[,3], data[,4], data[,7], data[,8], data[,9]),]
	n <- data[gsub(" ", "", data[,"Age"])=="0-4",]
	n <- n[gsub(" ", "", n[,"Rate"])=="h",]
	n <- n[gsub(" ", "", n[,"Sex"])=="Female",]
	n <- n[gsub(" ", "", n[,"Year"])=="2010",]
	n <- nrow(n)
	data2 <- data[1:(nrow(data)/n),c("Age","CountryID","Rate","Sex","Year","Result")]
	for (j in 1:(nrow(data)/n)) {
		data2[j,] <- data.frame(data[j*n-n+1,c("Age","CountryID","Rate","Sex","Year")], sum(data[(j*n-n+1):(j*n),"Result"]))
	}
	op_baseWrite("opasnet_base", data2, ident = "Op_en4691", who = "Teemu R", acttype = 5)
}

Unit

#

Result

{{#opasnet_base_link:Op_en4691}}


See also

References