Skip to content
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

Function as data #1527

Merged
merged 14 commits into from
Feb 1, 2016
Merged

Function as data #1527

merged 14 commits into from
Feb 1, 2016

Conversation

thomasp85
Copy link
Member

This is a follow up on PR #1486

Summary of changes:

  • Add fortify.function that returns function unchanged
  • Add layer_data method to Layer base class that takes the plot data as input and returns the data associated with the layer
  • Remove the need for waiver-check in map_layout
  • Add unit tests for layer_data method

Possible additions:

  • Documentation of function-as-data functionality somewhere (don't really know the best location for this - any idea?)

stop("Data function must return a data.frame")
}
return(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 this would be better with no returns and a final else block

@hadley
Copy link
Member

hadley commented Jan 31, 2016

This is looking good. A few points:

  • Can you please add a bullet point to NEWS?
  • Probably best to document this in layer()

@hadley hadley modified the milestone: v2.1.0 Jan 31, 2016
@thomasp85
Copy link
Member Author

All points have been addressed...

@@ -101,6 +128,20 @@ Layer <- ggproto("Layer", NULL,
cat(snakeize(class(self$position)[[1]]), "\n")
},

layer_data = function(self, plot_data) {
if (is.waive(self$data)) {
data <- plot_data
Copy link
Member

Choose a reason for hiding this comment

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

You can drop the data <- in all the alternatives

hadley added a commit that referenced this pull request Feb 1, 2016
@hadley hadley merged commit 0cd0bac into tidyverse:master Feb 1, 2016
@hadley
Copy link
Member

hadley commented Feb 1, 2016

One other idea now that I've merged it - what if the fortify happened in layer_data() as well?

@thomasp85
Copy link
Member Author

Possible error because of unknown data type will first happen when plotting - don't know if that is desirable?

@thomasp85
Copy link
Member Author

Should I redo the layer_data or is it merged and accepted and it was just a point for the future?

@hadley
Copy link
Member

hadley commented Feb 1, 2016

Just a point for the future. I fixed locally

@lock
Copy link

lock bot commented Jan 18, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants