unbekannt
2009-Apr-16 05:15 UTC
[R] Problem with a defined function which cannot access a function defined outside of the function
hi everyone, i have a problem with a function that i defined: the function needs to use a function which is defined outside the function but i realised that this is not working. a friend told me that this must be a problem with hidden parameters. a workaround works when i just define all parameters instead of using the function itself. now the problem is that i want to integrate the function and i'm not sure how to do it with this workaround since i have a plot of the function and a big vektor with all points of the plot on the x-axis only. Any help? Thanks -- View this message in context: http://www.nabble.com/Problem-with-a-defined-function-which-cannot-access-a-function-defined-outside-of-the-function-tp23071568p23071568.html Sent from the R help mailing list archive at Nabble.com.
Richard.Cotton at hsl.gov.uk
2009-Apr-16 08:22 UTC
[R] Problem with a defined function which cannot access a function defined outside of the function
> i have a problem with a function that i defined: > > the function needs to use a function which is defined outside thefunction> but > i realised that this is not working. a friend told me that this must bea> problem with > hidden parameters. > > a workaround works when i just define all parameters instead of usingthe> function > itself. now the problem is that i want to integrate the function andi'm> not > sure how to do it with this workaround since i have a plot of thefunction> and > a big vektor with all points of the plot on the x-axis only.I suggest you read up a little on the search path and how R does lexical scoping (sections 6.3.5 and 10.7 in R-Intro). The short version of that is that unless you specifically name the package that the function is from, R will look inside the current function, then in the global environment, then some other places. If you have problems with names of things being hidden, a quick hack is to rename the hidden item. If you want a less abstract answer then please post a commented, minimal, self-contained, reproducible code example. Regards, Richie. Mathematical Sciences Unit HSL ------------------------------------------------------------------------ ATTENTION: This message contains privileged and confidential inform...{{dropped:20}}