Currently, there is a broad set of functions pre-defined to handle missing values. As you’ve seen though, there are also functions that are missing “unaware”. There’s a proposal here to add a generic “lifting” function that would allow any function to propagate missing. The idea is that we can try out that functionality in a package and potentially add support for that to the language itself in the form of an operator or something.
Note how the f function here is called with the . broadcasting syntax: that automatically lifts the function and makes it deal with NA values, even if f doesn’t know about NA values at all.