Conditional Data Selection

DESCRIPTION:

Places values into an object like test according to the logical values in test.

USAGE:

ifelse(test, yes, no) 

REQUIRED ARGUMENTS:

test
logical object. Missing values (NA) are allowed.
yes
vector or bdVector containing values to be returned for elements with test equal to TRUE.
no
vector or bdVector containing values to be returned for elements with test equal to FALSE.

VALUE:

object with the attributes of test and data values from the values of yes or no depending on test . If yes or no are not as long as test, they will be repeated cyclically.

DETAILS:

NA values in test cause NAs in the result.

SEE ALSO:

, , , .

EXAMPLES:

# This example avoids the warning message from taking logs of  
# negative numbers. 
log(ifelse(x>0, x, NA))  # compare to the example in 'if'.