Why do we use arrow `<-` instead of equal `=` for assignment in #RStats :
It’s an historical choice: R comes from S, which used <- for assignment. S uses `<-` partly because it is inspired by APL, which had the ← operator for assignment, as it was developed for this keyboard, which has a key for arrow :
Not that at that time, with APL, the arrow was chosen because it distinguished from the equal operator (there were no `==` for testing equality).
See : softwarepreservation.org/projects/apl/B…
Until 2001, in R, `=` could only be used for assigning function arguments, like `fun(foo = "bar")` (remember that R was born in 1993).
So before 2001, the `<-` was the standard (and only way) to assign value into a variable : developer.r-project.org/equalAssign.ht…
Historical fun fact: in the beginning of R, the `_` was used as an assignment operator. It was deprecated in R 1 :
`=` was mainly added because other languages uses `=` as an assignment method, and because it increased compatibility with S-Plus. Nowadays, there are seldom any cases when you can’t use one in place of the other. It’s safe to use `=` almost everywhere.
Yet, `<-` is preferred and adviced in R Coding style guides:
One reason, if not historical, to prefer the `<-` is that it clearly states in which side you are making the assignment (you can assign from left to right or from right to left in R):
The RHS assignment can for example be used for assigning the result of a pipe:
There are some environment and precedence differences. For example, assignment with `=` is only done on a functional level, whereas `<-` does it on the top level when called inside the function() (but don’t do that):
There is also a difference in parsing when it comes to both these operators (but I guess this never happens in the real world), one failing and not the other:
It is also good practice because it clearly indicates the difference between function arguments and assignation:
Again, on environment assignment :
Also, here's an example of a little comparison of using `=` and `<-` to assign the result of an equality test:
Oh, and a little bit unrelated, but I almost forgot this one:

• • •

Missing some Tweet in this thread? You can try to force a refresh

Keep Current with Colin 🤘🌱🏃‍♀️

Colin 🤘🌱🏃‍♀️ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!


Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @_ColinFay

Aug 8, 2018
#RStats — What's up CRAN?

In the past 7 months:

🆕 1178 new 📦

🆓 18 unarchived 📦

⏹ 493 archived 📦
At the end of June, there were around 12500 📦 on the CRAN
Changes on CRAN check ✅

See stats.ox.ac.uk/pub/bdr/Rblas/… for more info
Read 9 tweets
Jul 25, 2018
💬 "If you're aiming at humans only, you can build a shiny app. If you want machines to access your data, build an API"

💬 "And remember that any other language can access your R API. You're opening a lot of doors."

Some important things to know when working with APIs:

🕸 About http requests : developer.mozilla.org/en-US/docs/Web…

🚀 About REST API : en.wikipedia.org/wiki/Represent…
Read 14 tweets
Jul 10, 2018
[Thread #RStats #Programming ]
Some important points taken from "Object-Oriented Programming, Functional Programming and R", by John M. Chambers
An article about what is Functional Programming (FP), and how does it differ from Object Oriented Programming (OOP) ?
Note that both these paradigms are used in R, and interact with each others.
Here’s the definition of what FP is :
- Programming == creating function
- Functions returns values computed from arguments (and only these)
- A function has no side effect
Read 20 tweets
May 12, 2018
Current status: looking for more memes to put in my @erum2018 talk.
#RStats #eRum2018
So far, I've got:
Read 8 tweets

Did Thread Reader help you today?

Support us! We are indie developers!

This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!


0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy


3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!