Skip to content
Prev 200771 / 398503 Next

Presentation of data in Graphical format

Well, from what you say it seems to me that you could also use Pareto 
charts together with some aggregation of data. But it depends on what you 
want to show to your audience. Below is some code which I slightly adapted 
form original author.

Regards
Petr

#----------------------------------------------------------------------------------------------------------------------
# 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, trunc.perc=.95, long.names=FALSE,...) 
{ 
        # 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]) 
                names<-as.character(names)[eff.ord]
                # plot barplot 

                        # get cumulative sum of effects 
                        sumeff <- cumsum(ef) 
                        m<-max(ef) 
                        sm<-sum(ef) 
                        sumeff <- sumeff/sm

                vyber<-sumeff>trunc.perc
                suma.ef<-sum(ef[vyber])
                sumeff<-c(sumeff[!vyber],1)*m
                ef<-c(ef[!vyber],suma.ef)
                names<-c(as.character(names[!vyber]),"Dalsi")
                ylimit<-max(ef) + max(ef)*0.19 
                ylimit<-c(0,ylimit) 
                par( mar=c(6, 4, 2, 4) + 0.1 , las=3) 
 
        if (long.names) {
        x<- barplot(ef, names.arg=names, ylim=ylimit, xlab=xlab, 
ylab=ylab, main=heading[i], plot=F, ...)
        x<- barplot(ef, ylim=ylimit, xlab=xlab, ylab=ylab, 
main=heading[i], ...)
        text(x,ylimit[2]/10, names, srt=90, adj=0, cex=.7)} else {

                x<-barplot(ef, names.arg=names, ylim=ylimit, xlab=xlab, 
ylab=ylab, main=heading[i], ...) 
                }


                if( indicate.percent == TRUE ){ 



                        # 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 


r-help-bounces at r-project.org napsal dne 18.11.2009 16:17:32:
"Secretary"
list
wrote:
Maybe
<sunitap22 at gmail.com>
<milton.ruser at gmail.com
tried
correctly. My
tasks"
code.
code.
http://www.R-project.org/posting-guide.html