Re: [R] How to find row maximum of two columns

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Thu 11 May 2006 - 14:05:54 EST

Try this:

pmax(tmax.m[,1], tmax.m[,2], na.rm = TRUE)

On 5/10/06, Dale Steele <Dale_Steele@brown.edu> wrote:
> Hello -- Given the 10x2 matrix below, my goal is to create a vector
> which contains the maximum of column 1 and column 2, or the only value
> if there is an NA in one column. I experimented with max.col without
> success. Thanks. --Dale
>
> > > tmax.m
> tmaxhme tmaxer
> [1,] 101.0 99.8
> [2,] 102.5 99.0
> [3,] 100.6 98.4
> [4,] NA 100.5
> [5,] 101.0 99.4
> [6,] NA 97.6
> [7,] NA 99.0
> [8,] 99.0 98.4
> [9,] NA 98.5
> [10,] NA 99.1
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu May 11 14:11:00 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 11 May 2006 - 16:10:03 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.