Re: [R] Add percentage to pie (was "(no subject)")

From: Sundar Dorai-Raj <sundar.dorai-raj_at_pdf.com>
Date: Mon 18 Sep 2006 - 15:15:18 GMT

ERICK YEGON said the following on 9/18/2006 8:22 AM:
> Hi Gurus, i have a small problem with working with graphs on R.
> Say i have data say bull-c(34,23,7,4) and i assign names to the elements in
> the brackets
> if i do
> Pie(bull) i get a pie chart of bull togtjer with the names.
> Question. How can i add values (percentages) in the graph
>
> Thanks
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.

(Please use a sensible subject line!)

Where do you want to add percentages? If next to the labels, then just use:

bull <- c(34, 23, 7, 4)
names(bull) <- LETTERS[seq(along = bull)] lbl <- sprintf("%s = %3.1f%s", names(bull), bull/sum(bull)*100, "%") pie(bull, lbl)

--sundar



R-help@stat.math.ethz.ch 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. Received on Tue Sep 19 01:20:22 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 18 Sep 2006 - 15:30:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.