[R] Pass Conditional & loop argument into a function

greatest.possible.newbie daniel.hoop at gmx.net
Wed Aug 8 18:50:55 CEST 2012


Thank you for your improvement suggestions.
I forgot to write the I() and it's clear that I have to specify the data
(which I was indicating with the '...' without explicitly writing it).

In this special case where I need a formula you really helped me with the
function as.formula() to transform the character string into a formula. But
what if I want to insert something else (not necessarily an object of the
class formula)? 

What I really need is something to remove the "" from the character string.
I already read things about eval(), substitute(), parse(text=...), assign()
and get() but that doesn't really help in my case or at least I don't know
to handle it the way I would need it.

Example:
foo <- function(data, variable.argument="data[,1],data[,2]") {
*variable.argument <- function that removes "" (variable.argument)*
cbind(variable.argument)
}

Normally the variable.argument is defined inside of the function as I did it
with the formula (my 1st question).

I hope you understand what I mean and thank you for your help!
Regards




--
View this message in context: http://r.789695.n4.nabble.com/Pass-Conditional-loop-argument-into-a-function-tp4639580p4639637.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list