Here is a performance comparison of the proposed methods in other answers.
> foo <- sapply(letters, function(x){runif(5)}, simplify = FALSE)
> microbenchmark::microbenchmark('k' %in% names(foo),
is.null(foo[['k']]),
exists('k', where = foo))
Unit: nanoseconds
expr min lq mean median uq max neval cld
"k" %in% names(foo) 467 933 1064.31 934 934 10730 100 a
is.null(foo[["k"]]) 0 0 168.50 1 467 3266 100 a
exists("k", where = foo) 6532 6998 7940.78 7232 7465 56917 100 b
If you are planing to use the list as a fast dictionary accessed many times, then the is.null
approach might be the only viable option. I assume it is O(1), while the %in%
approach is O(n)?