Hello Well I am relatively new so some of these issues may not fall under the subject that I have used. 1. How do I do a Pareto. Following is the approach I took. My data looks like this df2_9 Reaason.for.failure Frequency 1 Phy Conn 1 2 Power failure 3 3 Server software 29 4 Server hardware 2 5 Server out of mem 32 6 Inadequate bandwidth 1 I modified the data using:> df <- df2_9[order(df2_9$Frequency,decreasing=TRUE),] > x$Percent <- 100*(x$Frequency)/(sum(x$Frequency))ReasonCode Frequency ROF Percent 5 OOM 32 Out of Momeory 47.058824 3 SS 29 Server Software 42.647059 2 PF 3 Power failure 4.411765 4 SH 2 Server h/w 2.941176 1 PC 1 Physical Conn 1.470588 6 IB 1 Insuff b/w 1.470588 barplot(x$Percent, space=0, names.arg=x$ReasonCode, main="Pareto", legend.text=x$ReasonCode, ylab="% error") Here are my questions: 1. I could not print the data in ROF column below the bar charts, How to get full labels for each bar insted I createda new coumn ReasonCode just to fit below the bars. 2. Can I color code each bar differently 3. How to set limit on the y-axis - by deafult it shows 40, I want it show Y-axis till 50? 4. How to display value of each bar inside or on top of it? [[alternative HTML version deleted]]
Kapoor, Bharat wrote:> Hello > > Well I am relatively new so some of these issues may not fall under the subject that I have used. > > 1. How do I do a Pareto. Following is the approach I took. > > My data looks like this > df2_9 > Reaason.for.failure Frequency > > 1 Phy Conn 1 > > 2 Power failure 3 > > 3 Server software 29 > > 4 Server hardware 2 > > 5 Server out of mem 32 > > 6 Inadequate bandwidth 1 > > > I modified the data using: >> df <- df2_9[order(df2_9$Frequency,decreasing=TRUE),] >> x$Percent <- 100*(x$Frequency)/(sum(x$Frequency)) > > ReasonCode Frequency ROF Percent > > 5 OOM 32 Out of Momeory 47.058824 > > 3 SS 29 Server Software 42.647059 > > 2 PF 3 Power failure 4.411765 > > 4 SH 2 Server h/w 2.941176 > > 1 PC 1 Physical Conn 1.470588 > > 6 IB 1 Insuff b/w 1.470588 > > > > barplot(x$Percent, space=0, names.arg=x$ReasonCode, main="Pareto", legend.text=x$ReasonCode, ylab="% error") > > > > Here are my questions: > > 1. I could not print the data in ROF column below the bar charts, How to get full labels for each bar insted I createda new coumn ReasonCode just to fit below the bars.Well, either reduce the size of that kind of text (see "cex.axis" in ?par) or enlarge the corresponding margins (see "mar" in ?par)> 2. Can I color code each bar differentlySee "col" in ?barplot> 3. How to set limit on the y-axis - by deafult it shows 40, I want it show Y-axis till 50?See "ylim" in ?barplot> 4. How to display value of each bar inside or on top of it?See the values barplot() returns and combine them with a call to text(). Can you please read the help pages (and the posting guide) before posting? At least two of your questions are directly answered in ?barplot and the others by a help page ?barplot refers to: ?par. Uwe Ligges> > > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.
--- "Kapoor, Bharat " <k at chicagogsb.edu> wrote:> Hello > > Well I am relatively new so some of these issues may > not fall under the subject that I have used. > > 1. How do I do a Pareto.You might want to have a look at the qcc package. See http://www.stat.unipg.it/~luca/Rnews_2004-1-pag11-17.pdf for some information Following is the approach> I took. > > My data looks like this > df2_9 > Reaason.for.failure Frequency > > 1 Phy Conn 1 > > 2 Power failure 3 > > 3 Server software 29 > > 4 Server hardware 2 > > 5 Server out of mem 32 > > 6 Inadequate bandwidth 1 > > > I modified the data using: > > df <- > df2_9[order(df2_9$Frequency,decreasing=TRUE),] > > x$Percent <- 100*(x$Frequency)/(sum(x$Frequency)) > > ReasonCode Frequency ROF Percent > > 5 OOM 32 Out of Momeory 47.058824 > > 3 SS 29 Server Software 42.647059 > > 2 PF 3 Power failure 4.411765 > > 4 SH 2 Server h/w 2.941176 > > 1 PC 1 Physical Conn 1.470588 > > 6 IB 1 Insuff b/w 1.470588 > > > > barplot(x$Percent, space=0, names.arg=x$ReasonCode, > main="Pareto", legend.text=x$ReasonCode, ylab="% > error") > > > > Here are my questions: > > 1. I could not print the data in ROF column below > the bar charts, How to get full labels for each bar > insted I createda new coumn ReasonCode just to fit > below the bars.Given the lenght of the names you may have a problem. ?mtext is the obvious way but the names are too long. Have a look at http://finzi.psych.upenn.edu/R/Rhelp02a/archive/80007.html for rotating the labels or use the staxlab function in plotrix (see below)> 2. Can I color code each bar differently > > 3. How to set limit on the y-axis - by deafult > it shows 40, I want it show Y-axis till 50?library(plotrix) bp <- barplot(x$Percent, space=0, names.arg=x$ReasonCode, main="Pareto", legend.text=x$ReasonCode, ylab="% error", col=1:5, ylim=c(0,50), xaxt="n") staxlab(side=1, 1:6, x[,3])> 4. How to display value of each bar inside or on > top of it??text
--- "Kapoor, Bharat " <k at chicagogsb.edu> wrote:> 1. I could not print the data in ROF column below > the bar charts, How to get full labels for each bar > insted I createda new coumn ReasonCode just to fit > below the bars.You could plot the barchart horizontally, and increase the margins to allow the full labels: windows(6,4) #or x11(6,4) par(omd=c(0.2,1,0,1)) oo<-order(Frequency, decreasing=F) barplot(Frequency[oo],names.arg=Reason.for.failure[oo], horiz=T, las=1)
Maybe Matching Threads
- RequireSecuritySignature=1 and public share with guest not working
- MGCP parameters
- [Bug 59168] New: [nvc3/Quadro2000M] graphic garbage/corruption/noise on resume
- RequireSecuritySignature=1 and public share with guest not working
- Connecting to an Ericsson AXT121 with a Digium Wildcat E100 card