Hi!
Could you tell me how I can draw a graph with error bars?
Sorry, I don't use R that often and I couldn't find it easily in the
documentation.
TIA
myriam
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi,
Take a look at http://finzi.psych.upenn.edu/R/Rhelp02/archive/4124.html and
its thread.
You may want to bookmark Jonathan Baron's page,
http://finzi.psych.upenn.edu/search.html , which lets you search the r-help
archive and R documentations. You can find more information about error
bars there.
Hope this helps,
Kevin
------------------------------------------------
Ko-Kang Kevin Wang
Post Graduate PGDipSci Student
Department of Statistics
University of Auckland
New Zealand
www.stat.auckand.ac.nz/~kwan022
----- Original Message -----
From: "Myriam Abramson" <mabramso at gmu.edu>
To: <r-help at stat.math.ethz.ch>
Sent: Sunday, October 06, 2002 5:09 PM
Subject: [R] error bars in line plots
Hi!
Could you tell me how I can draw a graph with error bars?
Sorry, I don't use R that often and I couldn't find it easily in the
documentation.
TIA
--
myriam
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
|Hi!
|
|Could you tell me how I can draw a graph with error bars?
|Sorry, I don't use R that often and I couldn't find it easily in the
|documentation.
There is no errorbars function in the package. But you may easily construct
your own using segments(). I add my own versions below (actually, why not
put something similar into the base package?).
You may use it as:
plot(x,y)
errorbars(x,y, dy=dy)
The second function is for using with matplot().
Ott
-----------------------
errorbars <- function(x, y, dy=NULL, dx=NULL, ...) {
if(dy) {
segments(x, y-dy, x, y+dy, ...)
}
if(dx) {
segments(x-dx, y, x+dx, y, ...)
}
}
materrorbars <- function(x, y, dy=NULL, dx=NULL,
col=par("col"), lty=par("lty")) {
M <- ncol(y)
if(is.matrix(x))
N <- nrow(x)
else {
N <- length(x)
x <- matrix(x, N, M)
}
karv <- rep(col, length.out=M)
joon <- rep(lty, length.out=M)
if(!is.null(dy)) {
for(i in seq(M)) {
segments(x[,i], y[,i]-dy[,i], x[,i], y[,i]+dy[,i],
col=karv[i], lty=joon[i])
}
}
if(!is.null(dx)) {
for(i in seq(M)) {
segments(x[,i]-dx[,i], y[,i], x[,i]+dx[,i], y[,i],
col=karv[i], lty=joon[i])
}
}
}
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi,
>> Could you tell me how I can draw a graph with error bars?
"KKW" == Ko-Kang Kevin Wang <Ko-Kang at xtra.co.nz> writes:
KKW> Hi, Take a look at
KKW> http://finzi.psych.upenn.edu/R/Rhelp02/archive/4124.html and
KKW> its thread.
I just had a look at this page and expanded the examples a bit:
##Sample data:
mydat <- data.frame(x=1:10, y=1:10, dy=rnorm(10))
attach(mydat)
##Style of errorbars:
myangle=90 #Angle from shaft to edge of arrow head.
mylength=0.2#Length of arrow head in inches (!!!)
##One--sided errorbars:
plot(x,y,ylim=range(y,y+dy))
arrows(x,y,x,y+dy,angle=myangle,length=mylength)
##Two--sided errorbars:
plot(x,y,ylim=range(y-dy,y+dy))
arrows(x,y-dy,x,y+dy,code = 3,angle=myangle,length=mylength)
HTH
Volker
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On 6 Oct 2002, Myriam Abramson wrote:
|Hi!
|
|Could you tell me how I can draw a graph with error bars?
|Sorry, I don't use R that often and I couldn't find it easily in the
|documentation.
There is no errorbars function in the package. But you may easily construct
your own using segments(). I add my own versions below (actually, why not
put something similar into the base package?).
You may use it as:
plot(x,y)
errorbars(x,y, dy=dy)
The second function is for using with matplot().
Ott
-----------------------
errorbars <- function(x, y, dy=NULL, dx=NULL, ...) {
. . .
Also look at errbar and xYplot in the Hmisc library. -Frank Harrell
Frank E Harrell Jr Prof. of Biostatistics & Statistics
Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences
U. Virginia School of Medicine http://hesweb1.med.virginia.edu/biostat
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On 6 Oct 2002, Myriam Abramson wrote:
|Hi!
|
|Could you tell me how I can draw a graph with error bars?
|Sorry, I don't use R that often and I couldn't find it easily in the
|documentation.
and Ott Toomet responded
There is no errorbars function in the package. But you may easily construct
your own using segments(). I add my own versions below (actually, why not
put something similar into the base package?).
When I first met the problem I felt error bars should be added ... however
different disciplines have different ideas on what confidence intervals
should be and a 'packaged' version of 'error bars' may be less than
helpful. Maybe a short script should be put somewhere accessable? I built
my own script in a couple of minutes based on previous solutions given by
readers of r-help ... . It is actually a nice beginner exercise in R
programming, taking a few moments with every prospect of swift success,
Richard Rowe
Senior Lecturer
Department of Zoology and Tropical Ecology, James Cook University
Townsville, Queensland 4811, Australia
fax (61)7 47 25 1570
phone (61)7 47 81 4851
e-mail: Richard.Rowe at jcu.edu.au
http://www.jcu.edu.au/school/tbiol/zoology/homepage.html
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._