Suggestion: exprs()
vs tidyselect
#2011
Replies: 14 comments
-
@ddsjoberg , thanks for creating this issue. It is not too late because admiral is still experimental and we are working towards a "stable" version. At the moment, I would not use tidyselect for arguments like
@pharmaverse/admiral , what do others think? |
Beta Was this translation helpful? Give feedback.
-
Hey Daniel. Thank you for the feedback! I always thought the tidyverse packages were a monolith of stability, but after developing I tend to lean towards @bundfussr suggestion that we hold the course with On a side note, we have this |
Beta Was this translation helpful? Give feedback.
-
Thank you both for your thoughtful responses! 🌟 I hear and sympathize with the comments about changes in the tidyverse (particularly in the last ~10 months or so). It's been rough on the devs who chose tidyverse dependencies, and I've shared in that pain with you. When I chose the tidyverse deps, I thought it would simplify my life! That said, putting the user experience first is important in my view, even when it may make the life of the developer more difficult. Using the ubiquitous tidyselect notation speaks to that, rather than introducing a new kind of variable selection as it requires users to both learn the new selection construct and remember where that construct can and cannot be used (the second part being the more difficult piece for new users). Anyway, thank you for developing the package, and I fully understand if you choose to close this issue now! 🍁 |
Beta Was this translation helpful? Give feedback.
-
I tend to agree with @bms63 - staying with the One thing to note is that if we were to commit to this shift at some point in the future, then it would likely be after the release of admiral v1.0.0. For us, 1.0.0. implies a certain sense of stability, so I'd weary of making such a large, breaking change. |
Beta Was this translation helpful? Give feedback.
-
It sounds like generally, there is interested in moving toward a tidyselect framework, and the primary concern is that recent changes to tidyselect potentially signal fragility that would perhaps lead to breaks in the code. A couple of thoughts for the record to be reviewed at a future time point.
tidyselect_to_expr_list <- function(data, cols) {
# we can add a simple check here to see if user passed `exprs()` or `vars()`.
# we can print them a message of the correct notation AND then we correct the notation for them,
# so it would not break any existing code
# get character vector of selected column names
cols_chr <- colnames(dplyr::select(data, {{ cols }}))
# convert to list of symbols
lapply(cols_chr, function(x) rlang::sym(x))
}
# works when there are more than one variable selected
tidyselect_to_expr_list(mtcars, c(am, cyl)) |> str()
#> List of 2
#> $ : symbol am
#> $ : symbol cyl
rlang::exprs(am, cyl) |> str()
#> List of 2
#> $ : symbol am
#> $ : symbol cyl
# works with a single column as well
tidyselect_to_expr_list(mtcars, cyl) |> str()
#> List of 1
#> $ : symbol cyl
rlang::exprs(cyl) |> str()
#> List of 1
#> $ : symbol cyl
# works with tidyselect functions
tidyselect_to_expr_list(mtcars, dplyr::starts_with("d")) |> str()
#> List of 2
#> $ : symbol disp
#> $ : symbol drat Created on 2023-05-14 with reprex v2.0.2 I'll just reiterate that I think adopting tidyselect syntax as it is, without modification, will help with the adoption of admiral package, as opposed to implementing new selecting syntax that looks similar but with a few differences that are unique to the admiral package. Anyway, thanks for taking the time to go back and forth with me on this! |
Beta Was this translation helpful? Give feedback.
-
I'm personally quite sympathetic to @ddsjoberg's proposal. I never quite felt like |
Beta Was this translation helpful? Give feedback.
-
Hey @ddsjoberg - many thanks for being so engaged and concerned for our users. We are definitely interested in providing a good user experience! I will put onto the agenda for this week's core meeting. @pharmaverse/admiral can everyone come up to speed with this issue so we can discuss some more. If we do implement, I'm not sure we will do it in this release cycle as we are all chasing things at the moment. Just fyi: We have been operating in 3 month release cycles. We still see ourselves as experimental package and implementing user feedback has played a big role in each cycle. Hoping that at the end of the year we move to twice or even once a year releases! But still working out the kinks - pkg dev is hard! |
Beta Was this translation helpful? Give feedback.
-
Pkg dev is hard!! Thank you so much for doing it! |
Beta Was this translation helpful? Give feedback.
-
Hey all, sorry late to this discussion, Edoardo mentioned it to me in a call today. Thanks Daniel for sharing ideas for admiral! 👍 My 2 cents would be that I like the suggestion of giving users new and familiar feeling options in a way that doesn't break backward compatibility of their scripts. If this tidyselect suggested approach stabilizes and it helps R users better adapt to our package then I'd be in favour of giving users the option to use it with admiral. To Stefan's point though, we should be mindful of only adding whichever options we feel actually add value to justify the effort - for example I immediately see the benefit of I also don't think this should be highest on our backlog though, and could come later. If we do go this route, I'd say just cover this option once with an example in the Get Started page, rather than giving examples and these options repeated for every function page or vignette where we show @manciniedoardo and @bms63 you'll probably hear a million different viewpoints on this one and there's really no right or wrong, so trust you to make the overall call. |
Beta Was this translation helpful? Give feedback.
-
Please note that expressions like
does not work. |
Beta Was this translation helpful? Give feedback.
-
Hey @ddsjoberg heard you are on the admiral team!! Shall we make this happen for our next release (September)? |
Beta Was this translation helpful? Give feedback.
-
Awesome! Let's connect later this week or next to discuss details! (I am getting my tech setup at the moment...hopefully, i'll be up and running soon!) |
Beta Was this translation helpful? Give feedback.
-
#1990 and pharmaverse/admiraldev#233 on ice until we reached a fully-flushed out conclusion here |
Beta Was this translation helpful? Give feedback.
-
Brief summary of meeting with @bms63 and @manciniedoardo There is no plan to implement this feature, but may be picked up at some point in the future. Two reasons for not implementing now
@bms63 you mentioned that you'd like to see a small example how tidyselect could be implemented. In the script linked below there are two primary function:
https://github.com/pharmaverse/admiral/blob/tidyselect-example/R/utils-tidyselect.R |
Beta Was this translation helpful? Give feedback.
-
Background Information
Hello Team! 🍁 Thanks for all your amazing work on this package!
I know I am late to the conversation about the use of
exprs()
. But I wanted to make a suggestion.exprs()
for the user-facing inputs is a deviation from the tidyverse style of function inputs, and I don't think there is another package that uses this input type.exprs()
. So an input likeby_vars = exprs(USUBJID, PARAMCD)
, would then look like any of these (or any other tidyselect-consistent notation):by_vars = c(USUBJID, PARAMCD)
by_vars = any_of(c("USUBJID", "PARAMCD"))
by_vars = all_of(c("USUBJID", "PARAMCD"))
as_expr_list(<tidyselectors>)
. This small function could go at the top of any function that is expecting theexprs()
input. The function could also be written to handle inputs that usevars()
andexprs()
.Definition of Done
When users can utilize tidyselect notation in the admiral functions
Beta Was this translation helpful? Give feedback.
All reactions