0 votes
Good aftrenoon,

I am currently programming in R through the Dataiku and I have a very special question, how can I write this two logical characters in the same phrase? When I am working just with & or | separetly it is working, but once I try:

direction_final=
ifelse(directeur=="MINISTRE"|directeur=="PREFET"|(directeur=="MAIRE"&publique!=""),"Direction Général",""
)

So my question is it possible to use & and | together n the same part of the ifelse? And if it possible how can I get a good answer?

Thank you in advance for your answer.
asked by

1 Answer

0 votes
Hello,
 

R has two operators for 'and' and 'or', single or double: & / && and | / ||

You can google the precise difference between them but in your case you should use the double forms.

Regards,
Joachim
R&D engineer
answered by
Thank you fo the answer, but actually I can not, as "directeur" and so son it is a vector, and I want to apply "ifelse" for each row.

Thank you
Hum, this is definitely an R question and not DSS related but it looks indeed like a correct R syntax. I don't know what problem you are actually experiencing (in particular, error or output you don't expect) but I can tell you that you can indeed combine those boolean operators. If you find it easier to separate the computation into several steps that you can check individually, don't hesitate.
686 questions
705 answers
528 comments
434 users