In R programming language, is there any difference between "<-" and "="?
The true ideals of great philosophies always seem to get lost somewhere along the road..
In terms of assignment there is no difference. But note there are times when you can use the = but not <-. When you're specifying parameters inside of functions you need to use = and using <- will mess things up. I personally prefer to always use <- for assignment. That way we keep <- and = distinct (if I see a <- I know it's for assignment, if I see a = I know it's for something else). Plus if you want to do a global assign that is <-- but you can't do a global assign using =.
Also note that although I discourage the use of it you can do something like
and that will store that vector into x. If you use = you are forced to do a 'leftwise' assignment. Like I said I don't like to do this (at least if I'm writing a script) but it can come in handy if I compute something and have R evaluate it then realize I want to save it because you can just hit up and then add "-> var1" or whatever you want to call it.Code:
c(1,2,3,7) -> x
Advertise on Talk Stats