How to determine if a list is empty in R?

Solution 1:

Empty list is empty. It has no elements, but is still a list. List with no elements has length 0.

a = list()
if(length(a) == 0) {
    ....
}

Solution 2:

!is.null(listname) & class(listname) != "NULL" & class(listname) != "logical" & length(listname) != 0