[R] Passing expression as argument to do.call

Sebastien.Bihorel at cognigencorp.com Sebastien.Bihorel at cognigencorp.com
Fri Jul 3 04:31:58 CEST 2009


Damned, I did tried as.list but not list...

Thanks Hadley and Duncan for your quick replies

> On Thu, Jul 2, 2009 at 3:34 PM, Sebastien
> Bihorel<sebastien.bihorel at cognigencorp.com> wrote:
>> Dear R-users,
>>
>> I would like to know how expressions could be passed as arguments to
>> do.call
>> functions. As illustrated in the short example below, concatenating
>> lists
>> objects and an expression creates an expression object, which is not an
>> acceptable argument for do.call. Is there a way to avoid that?
>>
>> Thanks you
>>
>> Sebastien
>>
>>
>> foo <- list(x=1:10, y=1:10)
>> mylist <- list(pch=6, col=2)
>> title <- "1 microgram"
>> title2 <- expression ("1 " mu "g")
>>
>> do.call(plot, c(foo, mylist, main=title))
>>
>> class(c(foo, mylist, main=title2))
>>
>> do.call(plot, c(foo, mylist, main=title2))
>
> do.call(plot, c(foo, mylist, list(main=title2)))
>
> Both foo and myllist are already lists, but title2 isn't.
>
> Hadley
>
> --
> http://had.co.nz/
>




More information about the R-help mailing list