[R] Barchart, Pareto
Uwe Ligges
ligges at statistik.uni-dortmund.de
Sun Dec 9 16:34:51 CET 2007
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 differently
See "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.
More information about the R-help
mailing list