[R] compare variables and take largest value?

Duncan Murdoch murdoch.duncan at gmail.com
Thu Apr 22 17:14:40 CEST 2010


On 22/04/2010 11:07 AM, Vlatka Matkovic Puljic wrote:
> Hi!
>
> I have v1, v2 and v3 (data in v. ranges 1 to 4)
>
> v1
>    [1]   1   1   1   1 NaN   1   1   4   1   1   3
> v2
>    [1]   1   1   1   1   1   1   1   1   1   1   1
> v3
>    [1]   1   1   1   1   1   1   1   1   1   1   1
>
> I want R to compare entries in v1,v2,v3 and in v4 to put largest value
> (NA=0).
> For example. first line v4 would be 1, but last line v4 would be 3.
>
> What function should I use?
>
>   

pmax.

Duncan Murdoch



More information about the R-help mailing list