The goal is to create a function that will test to see if a number is in a vector.
For example, you would call it like this: function_name(3,c(1,2,3)) and it would return TRUE since 3 is one of the elements in the function.
My function works when the number is in the vector and it will output TRUE, but when the number is not in the vector, it will give the error, "missing value where TRUE/FALSE needed".
numCheck <- function(a,b){
for (num in b){
if (a == b[num]){
return(T)
break
}
else{
num <- num + 1
}
if (num > length(b)){
return(F)
break
}
}
}
print(numCheck(3,c(1,2,4)))