r - If else operator -


could please tell me switch in r returns second argument if true , third if false?

i have searched switch , if else function , have looked through documentation when using ubiquitous terms if , else seems hard identify solution.

i looking like:

f(true,1,2); f(false,1,2) [1] 1 [1] 2 

i working on reading through documentation of julia has made me aware of of gaps in knowledge in r. in julia there operator available.

(true  ? 1 : 2)  1 (false ? 1 : 2) 2 

simply ifelse

ifelse(true,1,2) ## [1] 1 ifelse(false,1,2) ## [1] 2 

Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -