Roman Luštrik
2010-Aug-26 06:59 UTC
[R] my function decided to stop working, problem with scoping?
Hello list. Until last week, I've been using my function without a problem. I can only imagine what has changed (no package updates), but all of a sudden, a custom function that uses raster::xyValues stopped working. For some reason, one of the values is not found, even though it's there. Here is a snippet of code from browser() call from within my custom function where everything goes awry. Browse[1]> effect.distance [1] 220.2045 # just to make sure effect.distance is there Browse[1]> unlist(xyValues(object = object, xy = origin.point, buffer effect.distance)) Error in .local(object, xy, ...) : object 'effect.distance' not found Browse[1]> traceback() 2: stop(gettextf("no function '%s' could be found", f), domain = NA) 1: getS3method("xyValues", "method") Browse[1]> environment() <environment: 0x137d2b14> Browse[1]> Q> environment()<environment: R_GlobalEnv>> effect.distanceError: object 'effect.distance' not found If I call the unlist(...) line in R_GlobalEnv, it seems to work fine. I'm wondering why this behavior? Cheers, Roman -- In God we trust, all others bring data. [[alternative HTML version deleted]]
Roman Luštrik
2010-Aug-26 07:28 UTC
[R] my function decided to stop working, problem with scoping?
To clarify, when I run the unlist(...) in R_GlobalEnv, I create all the necessary variables (including effect.distance). -- View this message in context: http://r.789695.n4.nabble.com/my-function-decided-to-stop-working-problem-with-scoping-tp2339228p2339263.html Sent from the R help mailing list archive at Nabble.com.