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

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sun, 27 Apr 2008 13:19:04 -0400

One can use sapply(data_frame, min) and similarly for max and median.

Another possibility is to use quantile and matplot like this

ir <- iris[1:3, 1:4] # sample data using builtin iris data set

mat <- t(sapply(ir, quantile, c(1, .5, 0))) matplot(mat, type = "hp", lty = 1, pch = 20, xaxt = "n",

    col = c("black", "red", "white"))
axis(1, seq_along(ir)) # or maybe axis(1, seq_along(ir), names(ir))

On Sun, Apr 27, 2008 at 12:25 PM, H.Jenkins <hjenkins_at_uvic.ca> wrote:
> 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",
> add=TRUE)
>
> 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
> pmedian?
>
> Regards,
> Hazel Jenkins
>
> ______________________________________________
> 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.
>



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. Received on Sun 27 Apr 2008 - 17:23:23 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 27 Apr 2008 - 17:30:32 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