1- # ' ggplot build function with enhanced return
2- # '
3- # ' This function builds on top of ggplot2::ggplot_build by
4- # ' Hadley Wickham <h.wickham@@gmail.com> and Winston Chang <winston@@stdout.org>
5- # ' (http://ggplot2.org, https://github.com/hadley/ggplot2).
6- # '
7- # ' @param plot ggplot2 plot
8- # ' @return List with (data, panel, plot, prestats.data) where prestats.data
9- # ' is the data as it is prior to calculate_stats() call
10- # ' @keywords internal
11- make_ggplot_build2 <- function (plot ) {
1+ make_ggplot_build2 <- local({
122 # Get body of the original function, in list form
133 ggplot_build2 <- ggplot2 :: ggplot_build
144 g_b <- as.list(body(ggplot_build2 ))
@@ -27,17 +17,19 @@ make_ggplot_build2 <- function(plot) {
2717
2818 # Assign the modified body back into the function
2919 body(ggplot_build2 ) <- as.call(g_b2 )
30- ggplot_build2( plot )
31- }
20+ ggplot_build2
21+ })
3222
33- # ' wrapper for build function
23+ # ' ggplot build function with enhanced return
3424# '
35- # ' It would be inefficient to perform each step found in make_ggplot_build2()
36- # ' every time we want to make use of its output.
25+ # ' This function builds on top of ggplot2::ggplot_build by
26+ # ' Hadley Wickham <h.wickham@@gmail.com> and Winston Chang <winston@@stdout.org>
27+ # ' (http://ggplot2.org, https://github.com/hadley/ggplot2).
3728# '
3829# ' @param plot ggplot2 plot
3930# ' @return List with (data, panel, plot, prestats.data) where prestats.data
4031# ' is the data as it is prior to calculate_stats() call
32+ # ' @export
4133# ' @keywords internal
4234ggplot_build2 <- function (plot ) {
4335 make_ggplot_build2(plot )
0 commit comments