r - Error in IF statement -
i trying construct if statement calculate statement if divisor greater 0 , return 0 if not. i'm have curly braces in right places r keeps giving me warning message saying
the condition has length >1 , first element used.
i understand means r evaluting first statement , ignoring else bit, know data there 0 entries variable in if condition
here current code
if (contributions$memcontamt > 0) { contributions$contamtratio <- contributions$empcontamt/contributions$memcontamt } else { contributions$contamtratio==0 }
thanks in advance
i suppose you're looking for
transform(contributions, contamtratio = "[<-"(empcontamt / memcontamt, memcontamt <= 0, 0))
Comments
Post a Comment