Monday 28 October 2019

R: Is there any performance difference between using = or

No measurable performance difference; more about readability and convention. It's all the computations that R is doing that will make or break you.




Use <-; "R In Action" says on page 7 that it's standard and other R developers will make fun of you if you don't.



There might be a deeper reason in the R documentation:




There are three different assignment operators: two of them have
leftwards and rightwards forms.



The operators <- and = assign into the environment in which they are
evaluated.




The operator <- can be used anywhere, whereas the operator = is only
allowed at the top level
(e.g., in the complete expression typed at
the command prompt) or as one of the subexpressions in a braced list
of expressions.




It's usually a good idea to use the proper idiom of the language you're writing in.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...