Hi Everyone- I hope all your papers are going well.
I am trying to write an R function that will produce a fairly complicated
graph by taking in, amongst other things, a variable name and then at one
point use setx in Zelig to produce a number of values. In setx the argument
name is actually the variable name, and here is where I run into trouble. I
can't seem to take an argument into my function and have it come out as an
argument in another function. So for example imagine this reduced example:
myfunction <- function(var) {
result <- setx(modelobj, data=data,
var
=seq(from=xrange[1], to=xrange[2], length.out=100))
}
You can see that I set the key piece of code out here. Its not the variable
itself I need there but the name of the variable. I have tried a character
string, assign(), paste(), substitute() and attribute(). For those that
know Stata this would be fairly easily solved by calling a local (in this
case the local is created automatically and you just write `var'). R is not
a macro language though, so I assume there is a better way I just haven't
found yet. Any thoughts?
Brandon
Show replies by date