-
Notifications
You must be signed in to change notification settings - Fork 37
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
Comments
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") |
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. |
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. |
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.
The text was updated successfully, but these errors were encountered: