-
-
Notifications
You must be signed in to change notification settings - Fork 584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use of = instead of <- confusing #319
Comments
Hi @EconGeo thanks for the question. Use of assignment symbol is a question of style and has no impact on results unless you do something like this (solution also shown in 3rd command): system.time(x = 1e9)
#> Error in system.time(x = 1e+09): unused argument (x = 1e+09)
system.time(x <- 1e9)
#> user system elapsed
#> 0 0 0
system.time({x = 1e9})
#> user system elapsed
#> 0 0 0 Created on 2018-10-05 by the reprex package (v0.2.1) For the reasoning behind our decision to use We know it's not everyone's cup of tea and would be up for changing it using the styler package. However it's how we (@Nowosad, @jannes-m and I) have ended-up writing and teaching R code after a few years and many teaching sessions of collective experience. There are some 'advanced' R materials that use We discussed changing it, and even considered creating a poll but, like the Brexit referendum, we cannot be sure we'll get the result we prefer ;) Furthermore we favour focusing on P.s. here's an old discussion of a similar issue (there's lots more out there!): csgillespie/efficientR#34 |
As someone who prefers
Furthermore, I consider it very bad parctice to do something along the lines of mean(myobject <- 1:10) which is sometimes used as an argument for In summary, I firmly believe that this choice really boils down to personal preference just the same as using piping (via e.g. dplyr), base style coding such as |
Yes, I'm a firm believer in I don't think it is very wise to be "thrown off" just by something related to personal preference. Besides, Usually I'm fine with multiple ways to do one thing, but in R, the two assignment operators (there are more) have been bothering me. The critical issue is that the two are not equivalent, so it is not purely a matter of personal taste. To sum it up, reasons why I don't use
I never push |
Fair enough. I understand your point of view, and didn't realize this was such a well established view in the community. Great book and thanks for publishing, wish it and the |
Well, not really a well established view. People who use |
Love the book. However, throughout the book you do not use the common assignment convention of
<-
and instead use an=
as in:world1 = dplyr::select(world, name_long, pop)
instead of
world1 <- dplyr::select(world, name_long, pop)
It throws me off as an advanced R user, and I think beginners reading the book will definitely be thrown off by this considering nearly every tutorial available on learning R follows the convention.
The text was updated successfully, but these errors were encountered: