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

Allow addition of custom objects #2309

Merged
merged 9 commits into from Oct 30, 2017

Conversation

Projects
None yet
2 participants
@thomasp85
Member

thomasp85 commented Oct 24, 2017

As discussed. This PR adds the possibility of developers writing custom behaviour for adding other objects than those defined by ggplot2 to a gg object.

It works by falling back to the add_to_ggplot() generic in add_ggplot(). A potential change to the PR would be to write add_to_ggplot() methods for all the build in classes as well thus completely removing the if else check from add_ggplot()

@thomasp85 thomasp85 requested a review from hadley Oct 24, 2017

@hadley

I think you should eliminate add_ggplot() by providing the appropriate methods to add_to_ggplot().

(It'll probably also need a different name - maybe ggplot_add()).

thomasp85 added some commits Oct 30, 2017

@@ -60,46 +60,88 @@ add_ggplot <- function(p, object, objectname) {
if (is.null(object)) return(p)

This comment has been minimized.

@hadley

hadley Oct 30, 2017

Member

This can now be a method of the generic

@hadley

hadley Oct 30, 2017

Member

This can now be a method of the generic

This comment has been minimized.

@thomasp85

thomasp85 Oct 30, 2017

Member

Oh - Didn’t knew you could dispatch on NULL

@thomasp85

thomasp85 Oct 30, 2017

Member

Oh - Didn’t knew you could dispatch on NULL

Show outdated Hide outdated R/plot-construction.r Outdated

thomasp85 added some commits Oct 30, 2017

@hadley

This comment has been minimized.

Show comment
Hide comment
@hadley

hadley Oct 30, 2017

Member

Does R CMD check pass locally?

Member

hadley commented Oct 30, 2017

Does R CMD check pass locally?

@thomasp85

This comment has been minimized.

Show comment
Hide comment
@thomasp85

thomasp85 Oct 30, 2017

Member

I have some strange (libc++abi.dylib: __cxa_guard_acquire detected deadlock) errors in unrelated tests that I'm currently troubleshooting

Member

thomasp85 commented Oct 30, 2017

I have some strange (libc++abi.dylib: __cxa_guard_acquire detected deadlock) errors in unrelated tests that I'm currently troubleshooting

@thomasp85

This comment has been minimized.

Show comment
Hide comment
@thomasp85

thomasp85 Oct 30, 2017

Member

OK - I'm up to speed again.

No It doesn't pass locally. The test method won't get dispatched to when called as part of Check, but works fine when pasted into the console. I guess the problem is the same - that S3 methods are not properly registered when defined within tests...

No idea how to properly test this then...

Member

thomasp85 commented Oct 30, 2017

OK - I'm up to speed again.

No It doesn't pass locally. The test method won't get dispatched to when called as part of Check, but works fine when pasted into the console. I guess the problem is the same - that S3 methods are not properly registered when defined within tests...

No idea how to properly test this then...

@hadley

This comment has been minimized.

Show comment
Hide comment
@hadley

hadley Oct 30, 2017

Member

I think you can just drop the test - if the S3 dispatch was failing, every plot would break.

Member

hadley commented Oct 30, 2017

I think you can just drop the test - if the S3 dispatch was failing, every plot would break.

thomasp85 added some commits Oct 30, 2017

@thomasp85

This comment has been minimized.

Show comment
Hide comment
@thomasp85

thomasp85 Oct 30, 2017

Member

I never thought I should live to hear you ask me to remove a test - this will haunt you 😛

Member

thomasp85 commented Oct 30, 2017

I never thought I should live to hear you ask me to remove a test - this will haunt you 😛

Merge branch 'tidyverse/master' into custom-object-add
# Conflicts:
#	NEWS.md

Merge branch 'tidyverse/master' into custom-object-add

# Conflicts:
#	NEWS.md

@hadley hadley merged commit 3c16f9c into tidyverse:master Oct 30, 2017

0 of 2 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
@hadley

This comment has been minimized.

Show comment
Hide comment
@hadley

hadley Oct 30, 2017

Member

Thanks!

Member

hadley commented Oct 30, 2017

Thanks!

@hadley hadley referenced this pull request Oct 30, 2017

Closed

make list() behave as NULL #2315

@lock lock bot locked as resolved and limited conversation to collaborators Jun 18, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.