[R] Variable c and function c
Duncan Murdoch
paypal at murdoch-sutherland.com
Tue Aug 21 17:46:07 CEST 2007
On 8/21/2007 11:07 AM, Vladimir Eremeev wrote:
> I have found the error in my script which was semi-automatically translated
> from the other person's MATLAB code.
>
> The error is that c was assigned a value inside a function.
> That is the function body contained the following instructions
> c<-nw*czr
> d<-nw*cz
> rFren<-0.5*(abs((cz-c)/(cz+c))^2+abs((d-czr)/(d+czr))^2)
> firstguess<-c( 0,0,0,3,0.5, 0 , 0 , 0.000001)
>
> I have already run this function and obtained the results, it was rather
> long process, therefore I don't want to rerun it.
>
> I was not given any warnings.
> How did the interpreter treat this?
> Will the result change, if I change the variable from "c" to, say, "c." ?
> This variable is not used anywhere else in the function.
When looking for a function, R will ignore variables that are not
functions. So what you show above is not an error, though it can be
confusing, so it's not a good idea.
Duncan Murdoch
More information about the R-help
mailing list