[R] Warning when trying to access a variable out of scope?
Steve Lianoglou
mailinglist.honeypot at gmail.com
Thu Jul 2 20:17:26 CEST 2009
Hi,
I was wondering if I could get R to warn me, or give me a rude
awakening somehow, if I'm accessing a variable that is out of my
function's scope.
For example, often times I'm creating a function as I'm testing it in
the REPL, copying and pasting between both.
As a simple example, I might end up with a function like:
f <- function(a, b) {
a + b.test
}
Where b.test was defined in my workspace as I'm mucking about in the
REPL, but "clearly" I should have written:
f <- function(a,b) {
a + b
}
I could go on for a while in my session w/o noticing the problem
(since b.test is in my global env), and unbeknownst to me, my function
will keep accessing the "b.test" variable when I really want it to
work on the "b" var that I'm passing in to it.
Is there some setting or someway I can get R to warn me that "b.test"
is being accessed outside the scope of my function?
Thanks,
-steve
--
Steve Lianoglou
Graduate Student: Physiology, Biophysics and Systems Biology
Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact
More information about the R-help
mailing list