[R] parallel max, min, and median of dataframe columns

H.Jenkins hjenkins at uvic.ca
Sun Apr 27 18:25:25 CEST 2008

Hello, all, 

I have a dataframe of three rows and umpteen columns. I want to show the 
maximum, minimum, and median with a vertical line and a central dot (I'd 
use a boxplot, but with only three data points, that's overkill; I can't 
just use points, because of overlap and some of the other data plotted on 
the graph). 

This works:
> boxplot(data_frame, col="transparent", border="dark grey", xaxt="n", 

But these don't:
> st <- c(1:19)
> segments(st, pmax(data_frame), st, pmin(data_frame))

(no, I haven't tried to put in the median points yet)

I can plot them individually with 
> segments(1, max(data_frame[,1]), 1, pmin(data_frame[,1]))
> points(1, median(fly_ash[,1]))
but that's a bit tedious. Is there a better way of vectorising these 
columns such that they will work with pmax? Is there something like a 

Hazel Jenkins

More information about the R-help mailing list