Try This:
############################################################################
#######################
#
# pareto. Produces a Pareto plot of effects.
#
# Parameters:
# effects - vector or matrix of effects to plot.
# names - vector of names to label the effects.
# xlab - String to display as the x axis label.
# ylab - String to display as the y axis label.
# perlab - Label for the cumulative percentage label.
# heading - Vector of names for plot heading.
#
pareto <- function(effects, names=NULL, xlab=NULL, ylab="Magnitude of
Effect", indicate.percent=TRUE,
perlab="Cumulative Percentage",
heading=NULL)
{
# set up graphics parameters, note: set las=2 for perpendicular
axis.
oldpar <- par( mar=c(6, 4, 2, 4) + 0.1 , las=3)
on.exit(par(oldpar))
if( ! is.matrix(effects)) effects<-as.matrix( effects )
for( i in 1:ncol(effects) )
{
if( i==2 ) oldpar$ask<-par(ask=TRUE)$ask
# draw bar plot
eff.ord <- rev(order(abs(effects[,i])))
ef <- abs(effects[eff.ord,i])
# plot barplot
ylimit<-max(ef) + max(ef)*0.19
ylimit<-c(0,ylimit)
par( mar=c(6, 4, 2, 4) + 0.1 , las=3)
x<-barplot(ef, names.arg=names[eff.ord], ylim=ylimit,
xlab=xlab, ylab=ylab, main=heading[i])
if( indicate.percent == TRUE ){
# get cumulative sum of effects
sumeff <- cumsum(ef)
m<-max(ef)
sm<-sum(ef)
sumeff <- m * sumeff/sm
# draws curve.
lines(x, sumeff, lty="solid", lwd=2, col="purple")
# draw 80% line
lines( c(0,max(x)), rep(0.8*m,2) )
# draw axis labling percentage.
at <- c(0:5)* m/5
axis(4, at=at,
labels=c("0","20","40","60","80","100"),
pos=max(x)+.6)
# add axis lables
par(las=0)
mtext(perlab, 4, line=2)
}
} # end for each col
}
Don Wingate
-----Original Message-----
From: owner-r-help at stat.math.ethz.ch
[mailto:owner-r-help at stat.math.ethz.ch]On Behalf Of Jesus Maria Frias
Celayeta
Sent: Tuesday, February 13, 2001 9:47 AM
To: R-help list
Subject: [R] Pareto Chart in R
Hi over there:
I would like to know if there is a function to plot a Pareto chart
of the
standardised effects of an aov() object, or an alternative to it.
my best regards,
IOsu
--
Jesus Maria Frias Celayeta, PhD.
Process Engineering Department
University College Cork,Cork
Ireland
phone: 353-21-903096
fax: 353-21-270249
http://www.ucc.ie/acad/departments/processeng/staff/friasj.html
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._