-
Notifications
You must be signed in to change notification settings - Fork 157
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
Drop aliases? #108
Comments
It appears to me that this would be a quite unpopular decision. (At least) some aliases are used quite a bit, AFAIK. Also, I'm not so sure everyone would think that some_data %>%
`colnames<-`(...) is as expressive and clean as some_data %>%
set_colnames(...) There are of course a few aliases that are potentially at risk of claiming useful names, such as Maybe I'm biased a bit away from seeing the "issue" exceeding the "value" b/c I use #' @importFrom magrittr %>% add extract for packages, and import::from(magrittr, "%>%", add, extract) in scripts. |
Basically I never attach magrittr because I don't want all the extra aliases, and I feel uncomfortable encouraging other people to do so because the risk of conflicts seem high. Why not move to a separate package? It would cause a little pain in the short run, but would also more delineate the scope of magrittr. |
I think a number of those aliases are very useful and increases the readability of code by magnitudes. |
@hadley do you ever encourage attachment? ;-) Just brainstorming, could one have, say, library(magrittr)
# access some expressive pipe aliases:
use_alises("inset", "use_series") and/or maybe library(magrittr)
define_aliases(add = "+", extract = "[") But still, I'm a little worried about the breakages this could cause for people. |
magrittr2 😉 @kristang I have no idea what |
@hadley You can set up a Twitter poll to decide what the users want? |
I fine with |
Still not sure what I think about moving the aliases, but here's a Magritte quote that would be suitable for such a package: "Everything we see hides another thing, we always want to see what is hidden by what we see." |
In many cases, there is actually less typing involved for the actual function vs the alias function ( I think it would be more useful to add simplified helper functions. For example, using save2 <- function(. = ., name, file = stop("'file' must be specified")) {
assign(name, .)
call_save <- call("save", ... = name, file = file)
eval(call_save)
}
# Example
all_letters <- c(letters, LETTERS) %>% sort() %T>% save2("all_letters", "all_letters.RData")
load("all_letters.RData", e <- new.env())
ls(envir = e)
# [1] "all_letters" In this example, |
Just bumped into magrittr::set_names when I actually wanted purrr::set_names I do find some of the aliases useful for code readability, so I'd hate to see all of them removed, but it'd be nice if set_names and extract had only one meaning within the tidyverse) :) |
Or move to another package?
I now feel like there's less need for them since I think
x %>% .[[1]]
orx %>%
>(5)
are just as expressive. I'm a bit concerned that they're very short names, so they claim a potentially quite expressive part of the language in a commonly used package.The text was updated successfully, but these errors were encountered: