Sal, 2011-05-24 tarihinde 08:41 -0500 saatinde, Robert Baer yazdÄ±:
> >> zcatav wrote:
> >>> How can i add data values or proportion values on bar or pie charts?
> >> You can add any text or numbers to any place of a graph with this
> >> command:
> >>> text(45,20,"some text")
> >> where: 45 is position on the X-axis and 20 - on the Y. Note that numbers
> >> denote the MIDDLE of the text,not its bottom-left corner. Must work
> >> perfectly for barplots, although not sure about pie-charts.
> > It's o.k. to add text,but i mean data values representing colon.
> > Let's we have following table;
> > A B
> > 1 2 3
> > 2 4 5
> > 3 3 6
> > I want to see these values (or % values) on representing bar. And if
> > possible R makes it automatically.
> > Thanks.
> Maybe this example will help for barplots.
> df = structure(list(A = c(2L, 4L, 3L), B = c(3L, 5L, 6L)),
> .Names = c("A", "B"), class = "data.frame",
> row.names = c("1", "2", "3"))
> vec = c(mean(df$A), mean(df$B)) #Bars assumed to be column means
> # bp stores the x locations for text
> bp = barplot(vec)
> # At top of bars
> text(bp, vec, vec, xpd = T) # xpd = T prevents clipping
> # Alternative with txt placement cleaner output
> text(bp, c(2, 2), round(vec,1))
> # Doing percents
> pc = 100*vec/sum(vec)
> text(bp, c(1, 1), paste(round(pc,1), '%', sep=' '))
> Robert W. Baer, Ph.D.
> Professor of Physiology
> Kirksville College of Osteopathic Medicine
> A. T. Still University of Health Sciences
> 800 W. Jefferson St.
> Kirksville, MO 63501
> FAX 660-626-2965
Thanks a lot. This is, what i want.
-- Zeki Ãatav http://zekicatav.tyih.gov.trReceived on Tue 24 May 2011 - 17:12:35 GMT
______________________________________________ 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.
- application/pgp-signature attachment: Bu dijital olarak imzalanmÄ±Å ileti parÃ§asÄ±dÄ±r
This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]
Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Archive generated by hypermail 2.2.0, at Tue 24 May 2011 - 17:20:09 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.
list of date sections of archive