Re: [Rd] How to build a list with missing values? What is missing, anyway?

From: Hadley Wickham <>
Date: Wed, 03 Oct 2012 22:10:00 -0500

On Wed, Oct 3, 2012 at 9:37 PM, Peter Meilstrup <> wrote:
> This is tangentially related to Hadley's question.
> Suppose I'm building a function programmatically; I have assembled an
> expression for the body and I know the names of the arguments it wants
> to take.
> Suppose I have some convenience function such that writing
> make_function(alist(a=, b=), quote(a+b), environment())
> is equivalent to writing
> function(a,b) a+b
> So how do I make the list that goes in the first argument? Suppose I
> start with a character vector of argument names. What I need is a list
> with names and quoted values, but the values are "empty".
> Say I have argnames <- c("a", "b", "c").
> >From that I want to construct the equivalent of alist(a=, b=, c=).

Here's one approach:

args <- alist()
for (n in argnames) {
  args[[n]] <- bquote()

You have to be really careful dealing with the missing symbol, because if R attempts to evaluate it, you get the missing argument error.


RStudio / Rice University

______________________________________________ mailing list
Received on Thu 04 Oct 2012 - 03:13:00 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 05 Oct 2012 - 06:42:51 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive