jeudi 30 mars 2017

ifelse in R to determine 2 conditions; one simple the other composite

Background:

I have two elements in an R function (see my R code below), type and width. The type element simply can be 1 or 2. But width can take any number.

Question:

Suppose there there two specific numbers that act as criteria for width. First number is 1. Second number is sqrt(2) / 2.

How can I say:

IF "type" is 1 AND "width" is NOT 1 AND ALSO (i.e., still type is 1) "width" is NOT sqrt(2) / 2, THEN "do ..."?

Can I use:

ifelse(type == 1 & width != 1 & width != sqrt(2)/2, do ..." ?

Aucun commentaire:

Enregistrer un commentaire