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
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 at 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
Something like pie(bull, labels=paste(names(bull),": ",bull,"%", sep="")) On 18/09/06, ERICK YEGON <kyegon@hotmail.com> wrote:> > 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. >-- ================================David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP [[alternative HTML version deleted]]