Skip to content

Allow rlang-style lambda expressions in stat_summary functions #3569

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

Merged
merged 6 commits into from
Dec 18, 2019

Conversation

dkahle
Copy link
Contributor

@dkahle dkahle commented Oct 14, 2019

No description provided.

@dkahle dkahle changed the title Closes #3568 Allow rlang-style lambda expressions in stat_summary functions Oct 14, 2019
Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I think it is safe to just substitute match.fun() with as_function()

Comment on lines 99 to 103
fun.data <- match.fun(fun.data)
if (is.formula(fun.data)) {
fun.data <- rlang::as_function(fun.data)
} else {
fun.data <- match.fun(fun.data)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just use as_function() for everything as it behaves correctly in all cases... We also import rlang so no need to prefix it

@yutannihilation
Copy link
Member

In general I think it is safe to just substitute match.fun() with as_function()

Agreed.

@thomasp85
Copy link
Member

@dkahle do you want to finish this off?

@dkahle
Copy link
Contributor Author

dkahle commented Dec 15, 2019

@thomasp85 Yep! Is that what you're looking for?

@@ -100,7 +100,7 @@ StatSummary2d <- ggproto("StatSummary2d", Stat,
xbin <- cut(data$x, xbreaks, include.lowest = TRUE, labels = FALSE)
ybin <- cut(data$y, ybreaks, include.lowest = TRUE, labels = FALSE)

if (is.formula(fun)) fun <- rlang::as_function(fun)
if (is.formula(fun)) fun <- as_function(fun)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just remove the is.formula check and call as_function() unconditionally... same with the other two places

@thomasp85
Copy link
Member

Apart from the small comment you just need to fix the conflict in the news file, and it is good to go... thanks

@dkahle
Copy link
Contributor Author

dkahle commented Dec 16, 2019

Hm. I pulled the news from upstream/master, updated it, and it still lists it as a conflict. What's the best way to resolve that? (Other than not wait two months before addressing your comments, that is.:)

@thomasp85
Copy link
Member

You should merge the master branch into this branch (make sure master is current)

And don’t worry about time-to-respond. We all have shifting focus🙂

Merge branch 'master' of https://github.com/tidyverse/ggplot2 into rlang-lambda-stat-summary

# Conflicts:
#	NEWS.md
@thomasp85
Copy link
Member

You should fix the merge conflict after merging in master. You still have the conflict in the NEWS file (the weird <<<<< HEAD notation)

Are you familiar with fixing merge conflicts or should I walk you through it?

@dkahle
Copy link
Contributor Author

dkahle commented Dec 17, 2019

Just seeing your second comment. I am familiar with merge conflicts; I thought I removed all merge conflict notes - did I miss something?

NEWS.md Outdated
@@ -1,5 +1,19 @@
# ggplot2 (development version)

<<<<<<< HEAD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is something here🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why yes, yes there is. 😂 I feel like this is the second time that my commit message should have a facepalm emoji.

I actually searched the project for <<<<, but I realize now I was only searching through the R script files... Stay tuned. Thanks!

Merge branch 'master' of https://github.com/tidyverse/ggplot2 into rlang-lambda-stat-summary

# Conflicts:
#	NEWS.md
@thomasp85 thomasp85 self-requested a review December 18, 2019 10:46
@thomasp85 thomasp85 merged commit 351eb41 into tidyverse:master Dec 18, 2019
@thomasp85
Copy link
Member

Thank you!

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

Successfully merging this pull request may close these issues.

3 participants