Just pass a named vector

f <- function(vars) { nms <- names(vec); ... }

f(c(DAP = var1, ALT = var2))


2009/12/1 Márcio Resende <mresende...@yahoo.com.br>

>
> 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@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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to