[R] how to manipulate ... in the argument list
Witold E Wolski
wewolski at gmail.com
Thu May 12 09:12:12 CEST 2016
Duncan suggested to use the argument explicitly and combine it with
the missing function which is for this problem also my preferred
solution:
image.2 <- function(x, col , breaks, ...){
# function is manipulating colors (adding a few)
# since it changes colors it needs to update breaks if defined.
if( !missing(breaks) ){
#manipulate breaks
image(x, col, breaks ,...)
}else{
image(x,col ,...)
}
}
It is good to know that I also could have used do.call.
I also learned yesterday that it is better to search for dot dot dot
argument or for elipsis instead of ...
best
On 11 May 2016 at 15:45, Vito M. R. Muggeo <vito.muggeo at unipa.it> wrote:
> Hi Witold,
> use do.call()
>
> list.args<-list(...)
>
> #modify 'list.args' (add/delete/modify)
>
> do.call(image, list.args)
>
> best,
> vito
>
>
> Il 11/05/2016 10.45, Witold E Wolski ha scritto:
>>
>> Hi,
>>
>> I am looking for a documentation describing how to manipulate the
>> "..." . Searching R-intro.html gives to many not relevant hits for
>> "..."
>>
>> What I want to do is something like this :
>>
>>
>> image.2 <- function(x, col , ...){
>> # function is manipulating colors (adding a few)
>> # since it changes colors it needs to update breaks if defined.
>>
>> breaks <- list(...)$breaks
>>
>> if( !is.null( list(...)$breaks ) ){
>> #manipulate breaks
>>
>> image(x, col, breaks = breaks ,...)
>>
>> }else{
>> image(x,col ,...)
>> }
>> }
>>
>> but in order to get it working I will need to remove breaks from ...
>> since otherwise I am getting multiple defined argument for breaks.
>>
>> So how to manipulate the "..." argument? Or should I use a different
>> pattern
>>
>> best
>>
>>
>>
>
> --
> ==============================================
> Vito M.R. Muggeo
> Dip.to Sc Statist e Matem `Vianelli'
> Università di Palermo
> viale delle Scienze, edificio 13
> 90128 Palermo - ITALY
> tel: 091 23895240
> fax: 091 485726
> http://dssm.unipa.it/vmuggeo
> Associate Editor, Statistical Modelling
> ===============================================
--
Witold Eryk Wolski
More information about the R-help
mailing list