[R] Using two (...) in a function

David Winsemius dwinsemius at comcast.net
Tue Dec 1 14:57:58 CET 2009

Seems pretty doubtful that a construction like (..., ...) is going to  
be accepted by the R interpreter. However, if you construct your  
function to handle two objects of equal length, one for the variable  
names and the other for their variances, there should be no problem.  
If yu want to handle a more general situation where you are passing an  
arbitrary list and want the first half interpreted as variable names  
and the second half interpreted as variances, well that can be  
programmed as well.

On Dec 1, 2009, at 8:30 AM, Márcio Resende wrote:

> Hello R-Helpers,
> I am not sure if it is a very simple question but I would like to  
> use two
> (...) in a function, for example,
> this is a script where I would like to input the variable names (in  
> one of
> the (...)) and the variances associated to those variables which are  
> not
> calculated in the script because there is a specific software to  
> calculate
> it (the other (...))
> data <- function ("DAP", "ALT", var1, var2){  #### My wish was to do
> somethin like function (...,...){
> Vec <- matrix(c("DAP", "ALT"))    ###here it would came the first  
> (...) Vec
> <- matrix(c(...))
> for (i in seq(along <- Vec)){
> caracteristica <- Vec[i]
> varF <- if (caracteristica == "DAP") var1 else var2    ##here I  
> would like
> to do something like #if   ###caracteristica == variable1) variance1  
> else if
> (caracteristica == variable2) variance2 else ...
> }
> }

At this point, because of the bizarrely placed comment symbols,  I am  
wondering if our mail clients are using the same end-of-line markers.

> but to turn this in a function, I would like to replace ("DAP",  
> "ALT") by
> any variable and var1, var2 to any variance, and not only necessary  
> 2, for
> example
> data ("variable1","variable2","variable3", "variance1", "variance2",
> "variance3")
> I am not sure if I made myself clear and if this is an "answerable"  
> doubt,
> anyway thank you vey much
> Márcio
> -- 

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

More information about the R-help mailing list