Hadley Wickham
2010-Oct-08 22:32 UTC
[Rd] What do you call the value that represents a missing argument?
Hi all, What's the official name for the value that represents a missing argument? e.g. formals(plot)$x str(formals(plot)$x) deparse(formals(plot)$x) is.symbol(formals(plot)$x) What's the correct way to create an object like this? (for example if you are manipulating the formals of a function to add an argument with no default value, as in http://stackoverflow.com/questions/3892580/). as.symbol("") returns an error. Both substitute() and bquote() return that object, but it's not obvious if this is on purpose. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/
Charles C. Berry
2010-Oct-09 03:08 UTC
[Rd] What do you call the value that represents a missing argument?
On Fri, 8 Oct 2010, Hadley Wickham wrote:> Hi all, > > What's the official name for the value that represents a missing argument? > > e.g. > formals(plot)$xSee ?list It is a 'dotted pair list' Are you looking for 'alist'? "alist handles its arguments as if they described function arguments. So the values are not evaluated, and tagged arguments with no value are allowed whereas list simply ignores them. alist is most often used in conjunction with formals."> alist(x=)$x==formals(plot)$x[1] TRUE>HTH, Chuck> str(formals(plot)$x) > deparse(formals(plot)$x) > is.symbol(formals(plot)$x) > > What's the correct way to create an object like this? (for example if > you are manipulating the formals of a function to add an argument with > no default value, as in http://stackoverflow.com/questions/3892580/). > as.symbol("") returns an error. Both substitute() and bquote() return > that object, but it's not obvious if this is on purpose. > > Hadley > > > -- > Assistant Professor / Dobelman Family Junior Chair > Department of Statistics / Rice University > http://had.co.nz/ > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:cberry at tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
Vitally S.
2010-Oct-09 09:33 UTC
[Rd] What do you call the value that represents a missing argument?
Hadley Wickham <hadley at rice.edu> writes:> What's the correct way to create an object like this? (for example if > you are manipulating the formals of a function to add an argument with > no default value, as in http://stackoverflow.com/questions/3892580/).as.symbol("") returns an error. Both substitute() and bquote() return > that object, but it's not obvious if this is on purpose.The question on stackoverflow was concerned with the creation of such an object: Obvious way: x <- alist(x=)$x Because the object like that seems to be a zero length name as.symbol("") #should be able to produce it quote() #is another meaningful candidate which does not work instead substitute() and bquote() works fine. Funny thing is that the behavior of bquote() and quote() are not expected to be different in this case. Vitally.> > Hadley