Re: [R] pyramid.plot: x-axis scale

2009-07-31 Thread ws
> Hi ws,
> You could tweak pyramid.plot in the plotrix package to do this.

I guess I will live without...

Unless you can spell the process out for doing that -- where is the source,
where would the package download be on my machine before (Mac OS X), who would I
send a working patch to.  If (the maintainer, right?) think it matters I can do
that, but I probably need a little handholding.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] pyramid.plot: x-axis scale

2009-07-30 Thread Jim Lemon

ws wrote:

Hi R-ers

Does anyone know how if there is a way to force pyramid plot where 
you determine the bottom axis range?  I want to compare many 
different pyramids, so I am hoping to force the bottom axis range

from 0% to 10%.

Here is the code so far, if it matters:

mk.pyr = function(data, pumas=NULL, fb.class=NULL, info="") {
# Makes population pyramids
# Assumes certain columns names in data -- SEX, AGEF, PUMA

males.i = data$SEX==1
females.i = data$SEX==1

if (is.null(pumas)) {
		xy.pop = 100*as.double(prop.table(xtabs(pwgtp~AGEF, 
data[males.i,])))
  	xx.pop = 100*as.double(prop.table(xtabs(pwgtp~AGEF, 
  data[females.i,])))
		 mytitle = sprintf("Population Pyramid for all pumas. %s.", 
info)


} else {
pumas.i = data$PUMA %in% pumas
xy.pop = 100*as.double(prop.table(
   xtabs(pwgtp~AGEF, data[males.i & pumas.i,])))
xx.pop = 100*as.double(prop.table(
   xtabs(pwgtp~AGEF, data[females.i & pumas.i ,])))
		mytitle = sprintf("Population Pyramid for %s", 
 paste(paste(pumas, collapse=", "), ".", info, "."))

}
  agelabels<-c("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-44","85+")
  xycol<-color.gradient(.5,.5,.5,18)
  xxcol<-color.gradient(.5,.5,.5,18)
  par(mar=pyramid.plot(xy.pop,xx.pop,labels=agelabels,
main=mytitle,xycol=xycol,xxcol=xxcol))
}

  

Hi ws,
You could tweak pyramid.plot in the plotrix package to do this.

Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] pyramid.plot: x-axis scale

2009-07-29 Thread ws
Hi R-ers

Does anyone know how if there is a way to force pyramid plot where 
you determine the bottom axis range?  I want to compare many 
different pyramids, so I am hoping to force the bottom axis range
from 0% to 10%.

Here is the code so far, if it matters:

mk.pyr = function(data, pumas=NULL, fb.class=NULL, info="") {
# Makes population pyramids
# Assumes certain columns names in data -- SEX, AGEF, PUMA

males.i = data$SEX==1
females.i = data$SEX==1

if (is.null(pumas)) {
xy.pop = 100*as.double(prop.table(xtabs(pwgtp~AGEF, 
data[males.i,])))
xx.pop = 100*as.double(prop.table(xtabs(pwgtp~AGEF, 
  data[females.i,])))
 mytitle = sprintf("Population Pyramid for all pumas. %s.", 
info)

} else {
pumas.i = data$PUMA %in% pumas
xy.pop = 100*as.double(prop.table(
   xtabs(pwgtp~AGEF, data[males.i & pumas.i,])))
xx.pop = 100*as.double(prop.table(
   xtabs(pwgtp~AGEF, data[females.i & pumas.i ,])))
mytitle = sprintf("Population Pyramid for %s", 
 paste(paste(pumas, collapse=", "), ".", info, "."))
}
  agelabels<-c("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-44","85+")
  xycol<-color.gradient(.5,.5,.5,18)
  xxcol<-color.gradient(.5,.5,.5,18)
  par(mar=pyramid.plot(xy.pop,xx.pop,labels=agelabels,
main=mytitle,xycol=xycol,xxcol=xxcol))
}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.