Try this: apply(replace(v <- rbind(v1, v2, v3), is.nan(v), 0), 2, max)
On Thu, Apr 22, 2010 at 12:24 PM, Vlatka Matkovic Puljic < v.matkovic.pul...@gmail.com> wrote: > Only thing that when I put na.rm=FALSE, > R is puting in v4 NA (as is largest) > and I want to see NA as zero (0, smallest value) > > 2010/4/22 Vlatka Matkovic Puljic <v.matkovic.pul...@gmail.com> > > > Thanx a lot! That's it! > > > > 2010/4/22 Duncan Murdoch <murdoch.dun...@gmail.com> > > > > 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 > >> > >> ______________________________________________ > >> R-help@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. > >> > > > > > > > > -- > > ************************** > > Vlatka Matkovic Puljic > > 095/8618 171 > > > > > > -- > ************************** > Vlatka Matkovic Puljic > 095/8618 171 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
______________________________________________ R-help@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.