How do you make an empty named list?

In R, the term "empty list" is usually understood to mean list(). But this isn't what you get when you delete all the elements from a named list:

x = list(a = 1)
x$a = NULL
print(x)                     # named list()
print(identical(x, list()))  # FALSE

Is there a slicker or more idiomatic way to get an empty named list?


  • Using setNames.

    setNames(list(), character(0))
    # named list()