Best Answer · By JanBask Data Science Expert
Answered on Jan 2, 2020
Let us create a function which returns TRUE and FALSE based on the condition
num_check <- function(num,v){
for (item in v){
if (item == num){
return(TRUE)
}
}
return(FALSE)
}
Now let us check whether it is working or not.
num_check(2,c(1,2,3))
Output
TRUE
num_check(2,c(1,4,5))
Output
FALSE