| 1 |
\name{list_named} |
| 2 |
\alias{list_} |
| 3 |
\title{Automatically Named list()} |
| 4 |
\description{ |
| 5 |
A version of \code{\link{list}(...)}, but with \dQuote{automatically} |
| 6 |
\emph{named} list components. |
| 7 |
} |
| 8 |
\details{ |
| 9 |
The names are extracted from \code{\link{sys.call}()}, and the function |
| 10 |
is written to be \emph{fast} (rather than easy to ready for the uninitiated ;-) |
| 11 |
} |
| 12 |
\usage{ |
| 13 |
list_(...) |
| 14 |
} |
| 15 |
\arguments{ |
| 16 |
\item{\dots}{components to make up the resulting \code{\link{list}}. |
| 17 |
Their variable names (or unevaluated expressions in the call) will |
| 18 |
become the \code{\link{names}(.)} of the result.} |
| 19 |
} |
| 20 |
\value{ |
| 21 |
a \code{\link{list}} with the components in the arguments with |
| 22 |
\code{\link{names}} taken from their call to \code{list_(..)}. |
| 23 |
} |
| 24 |
\author{Martin Maechler} |
| 25 |
\seealso{ |
| 26 |
\code{\link{list}}, \code{\link{names}} |
| 27 |
} |
| 28 |
\examples{ |
| 29 |
a <- 1:4; lett <- letters[1:9]; CH <- "Suisse" |
| 30 |
all.equal(list (a, lett), |
| 31 |
list_(a, lett)) # "names for current but not for target" |
| 32 |
str(list(a, lett, CH)) # [[1]], [[2]], .. (no names) |
| 33 |
str(list_(a, lett, CH))# $a $lett .. |
| 34 |
|
| 35 |
stopifnot(identical( list (a, lett, CH), |
| 36 |
unname(L <- list_(a, lett, CH))), |
| 37 |
is.list(L), names(L) == c("a", "lett", "CH"), |
| 38 |
identical(lett, L$lett) ## etc |
| 39 |
) |
| 40 |
|
| 41 |
## The function is currently defined as |
| 42 |
function (...) `names<-`(list(...), vapply(sys.call()[-1L], as.character, "")) |
| 43 |
} |
| 44 |
\keyword{utilities} |