0

this method of creating a population pyramid worked for me once, and somehow freezes my RStudio now, so I need to restart it each time and I do not progress...

Would be grateful if someone could let me know what makes R stop...

   Males <- c(26069148,1698171,1521271,1577011,1706618,1810404,1820536,1754903,1765582,1923441,1919758,1687729,1481745,1557140,1217965,967953,755703,519650,275459,108109)
Females <- c(26943308,1620278,1451361,1503918,1633647,1784917,1830345,1754318,1783534,1962493,1960057,1712366,1515247,1615137,1290189,1076176,913642,739123,500852,295708)

Males
Females


AgeGroup= c("All Ages", "0-4", "5-9", "10-14", "15-19", "20-24", "25-29", "30-34", "35-39", "40-44", "45-49", "50-54", "55-59", "60-64", "65-69", "70-74", "75-79", "80-84", "85-89", "90 and older")

library(plotrix)

xy.people <- Males
xx.people <- Females

mcol<-color.gradient(c(0,0,0.5,1),c(0,0,0.5,1),c(1,1,0.5,1),18)
fcol<-color.gradient(c(1,1,0.5,1),c(0.5,0.5,0.5,1),c(0.5,0.5,0.5,1),18)
par(mar=pyramid.plot(xy.people,xx.people,labels=AgeGroup,top.labels=c("Male","Age Group","Female"),
                 main="England",lxcol=mcol,rxcol=fcol,
                 gap=0, labelcex = 0.5, unit="No. of People"))

it works if I add the following to the code: laxlab=seq(0,1e7,by=1e6),raxlab=seq(0,1e7,by=1e6)) as explained in this post: R pyramid plot very slow if fed with larger numbers

Community
  • 1
  • 1
Asiack
  • 47
  • 8
  • 1
    This sort of question should be posed to the RStudio people. That last `par` call looks "just wrong". Why would you past the output of pyramid.plot to the 'mar' argument? – IRTFM Jul 11 '14 at 17:35
  • i guess i copy-pasted it from my old code without thinking. surprisingly the code works with both par(mar= and without it part.. Thank you for pointing it out. – Asiack Jul 11 '14 at 17:57

0 Answers0