Hi,

On Jul 24, 2009, at 11:43 AM, Dieter Menne wrote:

mfreidin wrote:

I have a matrix containing means and CIs (lower and upper in two columns, so three columns for every data point) for several points. I have to build a graph of these means accompained by the CIs (as wiskers). No problems with making the graph of means, but I don't know how to introduce CIs.


xYplot in package Hmisc (not the uppercase Y)

Rolling your own isn't all that difficult either (especially when someone else has written such a function already :-).

This code was lifted straight out of lars package (called when plotting CV error):

error.bars <- function (x, upper, lower, width = 0.02, ...) {
    xlim <- range(x)
    barw <- diff(xlim) * width
    segments(x, upper, x, lower, ...)
    segments(x - barw, upper, x + barw, upper, ...)
    segments(x - barw, lower, x + barw, lower, ...)
    range(upper, lower)
}

``x`` is the x positions you want to draw the whiskers
``upper`` is a vector of length x and indicates the top of the whisker at each x ``lower`` is a vector of length x and indicates the bottom of the whisker at each x ``width`` is the length of the "hat" to put at each whisker (typically 1/x works well here, too)

HTH,
-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
  |  Memorial Sloan-Kettering Cancer Center
  |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

______________________________________________
R-help@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.

Reply via email to