Skip to content

Instantly share code, notes, and snippets.

@ogra
Created March 26, 2011 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ogra/888232 to your computer and use it in GitHub Desktop.
Save ogra/888232 to your computer and use it in GitHub Desktop.
Ukraine population pyramid 1985
require(plotrix)
data = read.csv("UNPop_ukraine_age_sex_1985-2010.csv")
data = data[-379, ]
data1 = subset(data, select=c("Sex", "Year", "Age", "Value"))
xy.pop1985 = subset(data1[data1$Sex=="Male" & data1$Year==1985,], select="Value")$Value
xx.pop1985 = subset(data1[data1$Sex=="Female" & data1$Year==1985,], select="Value")$Value
agelabels = unique(subset(data1, select="Age")$Age)
xx.pop1985ratio = xx.pop1985 / sum(xx.pop1985) * 100
xy.pop1985ratio = xy.pop1985 / sum(xy.pop1985) * 100
par(mar=pyramid.plot(xy.pop1985ratio,xx.pop1985ratio,labels=agelabels,main="Ukraine population pyramid 1985",gap=1.5,show.values=TRUE))
@ogra
Copy link
Author

ogra commented Jul 2, 2011

header = TRUE by default with read.csv()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment