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

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -