By default, R creates an unnamed list:
x <- 42
y <- "John"
z <- 1:7
list(x, y, z)
# [[1]]
# [1] 42
#
# [[2]]
# [1] "John"
#
# [[3]]
# [1] 1 2 3 4 5 6 7
This below seems to do what I want, but I feel I missed something crucial, as why isn't this the default behaviour?
namedlist <- function(...) {
L <- list(...)
names(L) <- unlist( lapply( as.list( match.call())[-1L],
as.character))
return( L )
}