I don't understand the difference between "=" and "==" in R. I have a few questions:
- Why does
=assign when in a script but not when in a function? - Why should I use
<-when=exists? Is there a difference?
I don't understand the difference between "=" and "==" in R. I have a few questions:
= assign when in a script but not when in a function?<- when = exists? Is there a difference?I've never written a line of r but I can tell you with almost total certainty that = is the assignment operator, while == is the equality operator. A quick google search will easily answer questions you have like this.
It seems that the arrow operator <- is more typically used in R for assignment, than =.
Assignment:
x = 3
x <- 3
Test for equality:
if (x == 3)
= is used for assignment and setting function parameters.
== is used for comparing variables: testing for equality.