Skip to content
Prev 248487 / 398502 Next

Trouble variable scoping a function writing with get()

It's looking for an object named "b" in the frame of the function.
There is none. You need to specify

get(response, pos = parent.frame())

## or maybe even

get(response, pos= globalenv())

HOWEVER, this is **exactly** why you shouldn't do this! Instead of
passing in the name of the object, pass in the object itself (response
= b, not response = "b") and forget about using get(). Then it
**would** work as writted without getting tangled up in scoping. The
whole point local (to the function) scope and call by value is to
avoid exactly the sort of mess that you've gotten yourself into. Stick
with R's programming paradigms in R rather than trying to impose
others and life will be simpler and sweeter.

-- Bert
On Wed, Jan 26, 2011 at 2:21 PM, Pat Schmitz <pschmitz at illinois.edu> wrote: