[R] Using two (...) in a function
Benilton Carvalho
bcarvalh at jhsph.edu
Tue Dec 1 14:41:57 CET 2009
isn't it simpler just to pass two vectors, say v1 and v2, in which one contains the object names and the other has the associated variances? (btw, "data" isn't a good function name)
myData <- function(v1, v2){
Vec <- matrix(v1)
varF <- v2
}
I may have misunderstood your question, but IMHO all you need is to guarantee that v1 and v2 are properly aligned.
Cheers,
b
On Dec 1, 2009, at 11: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 ...
> }
> }
>
> 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
> --
> View this message in context: http://n4.nabble.com/Using-two-in-a-function-tp932200p932200.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list