Skip to content

seeking a help on if function

2 messages · Agnes Ayang, Berend Hasselman

#
On 17-12-2012, at 08:45, Agnes Ayang wrote:

            
Don't use the quotes: you want the variable or object a not the character string "a".

ssdw<-ifelse(gw1==gw2, a, b)

Since gw1 and gw2 are scalars you can dispense with the ifelse.
This will do as well

ssdw <- if(gw1==gw2) a else b

or

if(gw1==gw2) ssdw <- a else ssdw <- b

Berend