Skip to content
Prev 333400 / 398506 Next

if else in R

Which means you should use the ifelse function...

ab$c <- ifelse( ab$b>0, ab$a/ab$b, 0 )
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
Nick Matzke <matzke at berkeley.edu> wrote: