I had misunderstood the function missing() for several years. Originally I thought it only applies to an argument that does not have a default or user-specified value. For example, this is fairly easy to understand:
f = function(x) {
missing(x)
}
f() # should be TRUE
One day I was surprised to find that this also returned TRUE:
f = function(x = 1) {
missing(x)
}
f()
What?! x does have a default value 1; why is it considered missing? Then I realized missing() really meant “argument/value not passed” (to the function call).
Below is a yet more surprising fact that I discovered:
f = function(x) {
missing(x)
}
g = function(y) {
f(y)
}
g() # still returns TRUE
I was surprised because when g calls f(y), y does not exist, yet it still worked. It looks like we did pass y (whatever it really is) to f(), but f() sees nothing. Sounds like fun of lazy evaluation or something.
Anyway, I don’t recommend using missing(). It is fragile and you may break it unintentionally. Per its help page:
missing(x)is only reliable ifxhas not been altered since entering the function […]
What I often do is to set the defautl value to NA or NULL, and use is.na() / is.null() to test if the default value was explicitly changed by the user. Of course, this has a different meaning with missing(), but it is more robust. In particular, NA works better when the function is used in a vectorized call, e.g., mapply().
Donate
As a freelancer (currently working as a contractor) and a dad of three kids, I truly appreciate your donation to support my writing and open-source software development! Your contribution helps me cope with financial uncertainty better, so I can spend more time on producing high-quality content and software. You can make a donation through methods below.
-
Venmo:
@yihui_xie, or Zelle:xie@yihui.name -
Paypal
-
If you have a Paypal account, you can follow the link https://paypal.me/YihuiXie or find me on Paypal via my email
xie@yihui.name. Please choose the payment type as “Family and Friends” (instead of “Goods and Services”) to avoid extra fees. -
If you don’t have Paypal, you may donate through this link via your debit or credit card. Paypal will charge a fee on my side.
-
-
Other ways:
WeChat Pay (微信支付:谢益辉) Alipay (支付宝:谢益辉) 

When sending money, please be sure to add a note “gift” or “donation” if possible, so it won’t be treated as my taxable income but a genuine gift. Needless to say, donation is completely voluntary and I appreciate any amount you can give.
Please feel free to email me if you prefer a different way to give. Thank you very much!
I’ll give back a significant portion of the donations to the open-source community and charities. For the record, I received about $30,000 in total (before tax) in 2024-25, and gave back about $15,000 (after tax).