stbl hex logoThe Design of Everyday R Functions

Make it obvious what the function does

:: notes - Show a my_function <- function(x, y) {} example. - Have something real in mind. Maybe F to C conversion? No, something with at least 2 inputs. - Rename to make it obvious what’s expected. - Defaults can also help make things obvious. ::

Forgive “close enough” input

:: notes - Show stbl::to_int() vs as.integer() (NAs introduced) vs over-strict vctrs::vec_cast("1", integer()) - Use this to lead to error section. ::

Tell users how to fix mistakes

:: notes - Show error messages before stbl. x + y throws fun, hard to understand errors. - Show stbl-style errors. ::