Learning number 1: make functions fail early

When writing your own functions, avoid conversion of types without warning. For example, this function only works on characters:

my_nchar <- function(x, result = 0){ if(x == …