Skip to content
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

R elegance #3

Open
aviertio opened this issue Jun 13, 2019 · 3 comments
Open

R elegance #3

aviertio opened this issue Jun 13, 2019 · 3 comments

Comments

@aviertio
Copy link

No R style I know of suggests opening curly brace on its own line and all the guides I've read dictate it should be on the opening line. This current version is not representative of R practices and would be more elegant with the one line less.

@eddelbuettel eddelbuettel mentioned this issue Jun 13, 2019
@WerthPADOH
Copy link

I also found this part less than convincing. Not that I need convincing; I personally know idiomatic Python is much more legible than idiomatic R. The difference shows up in nested code or chained operations:

# Python
try:
    x = 1 + '2'
    y = x + 3
except TypeError:
    pass

string.lower().replace('a', 'b')
# R
tryCatch({
    x = 1 + '2'
    y = x + 3
  },
  error = function(err) {
    NULL
  }
)

# nested chaining
gsub("a", "b", tolower(string))
# magrittr chaining
string %>%
  tolower() %>%
  str_replace_all("a", "b")

@matloff
Copy link
Owner

matloff commented Jun 13, 2019

Sure, the real elegance comes in my complex situations. Note, though, that an indenting error may not be caught in nested settings, which could be real trouble.

@matloff matloff closed this as completed Jun 13, 2019
@matloff
Copy link
Owner

matloff commented Jun 13, 2019

In terms of R style, come on! Let people develop their own. I used to put { on the same line as 'function' but changed because in Vim one can easily go to the opening that way.

@matloff matloff reopened this Jun 13, 2019
@matloff matloff closed this as completed Jun 13, 2019
@matloff matloff reopened this Jun 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants