Re: [R] Issue with special assignment operator

2014-03-17 Thread Jeff Newmiller
Clearly not. I don't know why you think that should be the expected behaviour. They are different variables. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#.

Re: [R] Issue with special assignment operator

2014-03-17 Thread AROONALOK PYNE
Thanks a lot Jeff for the reply. I usually do what you said i.e, return a value from the function and save it in the calling environment when I call the function, but I just wanted to experiment with the special assignment operator. Could you clarify a small doubt of mine : I agree that x refers t

Re: [R] Issue with special assignment operator

2014-03-16 Thread Jeff Newmiller
Because x refers to the local version, not the global one. In case you have not read this before, using <<- is a really really bad idea. Your code will become confusing and likely be wrong if you ignore this warning. Return a value from the function and save it in the calling environment when y

[R] Issue with special assignment operator

2014-03-16 Thread AROONALOK PYNE
Hi Please explain why the function 'foo()' is not printing x as 8 in the following code : > foo <- function(){ + x <- 10 + if(x){ + x <<- 8 + } + print(x) + } > foo() [1] 10 > x [1] 8 > -- *AROONALOK PYNE* BE Graduate Department Of Computer Science And Engineering Jadavpur University, Kolkata-