R - Check if error message is due to missing arguments

Viewed 30

I would like to check if an error message is due to missing arguments that have no default values. I'm not sure how to do this since such error messages don't appear to have a unique class or identifier that distinguishes them from other error messages.

I can check if the message contains the words 'no default', but this doesn't seem very robust:

res = try(mean(rm = T), silent = T)

grepl('no default', attr(res, "condition"))
[1] TRUE
0 Answers
Related