On 16/07/2010 10:57 AM, linda.s wrote:
Hi.
I am a beginner. What is the difference between:
x<-2
and
x=2

It depends on the context. "x <- 2" always assigns the value 2 to the variable named x. Typed as an isolated command, that's what "x = 2" does too. However, when used as an argument to a function, e.g. f(x = 2), it associates the value 2 to the *argument* matched by x in the function call. This is occasionally confusing, so many people recommend that you always use "x <- 2" when you mean to do an assignment, and reserve the use of "=" for function arguments.

Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
  • [R] assign linda.s
    • Re: [R] assign Duncan Murdoch

Reply via email to