[R] simple line plots?

Ashish Ranpura buddhahead at ranpura.com
Mon Sep 5 20:05:58 CEST 2005


I've spent quite a lot of the day trying to construct a fairly  
standard line plot in R, and I have the feeling there is a simple way  
that I haven't discovered.

I have a large vector of measurements (TIME), and each measurement  
falls into one of three categories (PHASE). For each PHASE value, I  
want a mean of the corresponding TIME measurements plotted as a point  
along with standard error bars. I'd like the three resulting point  
connected with line segments.

I'd like to have two data series like this plotted on the same graph  
-- one in red, one in blue.

Excel, as awful as it is, does this kind of graph quite easily.

After sifting through the scattered documentation, the best I could  
do was to store the mean values of the three points, plot those three  
numbers against the values 1,2, and 3, then use the arrows() function  
to draw error bars on each one. This is a LOT of manual effort, as  
you can imagine (in addition to the means I have to calculate the  
standard errors for each point, and I still don't know how to draw  
each of the three line segments I need).

Any suggestions?

Thanks,

--Ashish.


-----
Ashish Ranpura
Institute of Cognitive Neuroscience
University College London
17 Queen Square
LONDON WC1N 3AR




More information about the R-help mailing list