I want to loop over a vector and send the values as parameters to a function. One of the values I want to send is NULL. This is what I’ve been trying
things <- c('M','F',NULL)
for (thing in things){
doSomething(thing)
}
But the loop ignores the NULL value. Any suggestions?
The loop doesn’t ignore it. Look at
thingsand you’ll see that theNULLisn’t there.You can’t mix types in a vector, so you can’t have both
"character"and"NULL"types in the same vector. Use a list instead.