Usually argument of length 0 is caused by NULL in if statement.
For example,
X = NULL
Y = NA
Z = 1
if(is.na(X)) X = 1
# since is.na(NULL) is logical(0), which have length 0.
# this will cause "argument of length 0" error
if(is.na(Y)) Y = 1
# work fine
if(is.na(Z)) Z = 1
# work fine.
I think li3 contains NULL. I don't know what me2 function does, but you should check that first.