What is the difference between <-, = and ==?

Tagged: , ,

  • What is the difference between <-, = and ==?

    Posted by Patrick on 21 October 2024 at 19:40

    This <- is used for assignment; to assign a value to a variable (e.g. x <-3). While <- is more frequently used, the equal to sign (=) is also used for assignment in specific situations (such as function arguments). But we recommend you use <- in R programming to avoid future conflicts.

    The double equal to (==) sign verifies whether two values are equal (e.g. x==5 returns TRUE or FALSE)

    Patrick replied 7 months, 2 weeks ago 2 Members · 2 Replies
  • 2 Replies
  • Ibrahim

    Moderator
    24 October 2024 at 14:04

    To make matters more confusing, there is also -> assignment

    3 -> x which assigns 3 to x. R for fun, I guess

    • Patrick

      Member
      24 October 2024 at 18:58

      You are right. To avoid all these confusions and conflicts, it is recommended that programmers use <- for assignments. JUST TO BE ON THE SAFER SIDE.

Log in to reply.