1) change proto(Geom to proto(ggplot2:::Geom for geom_boxplot; similarly change proto(Stat to proto(ggplot2:::Stat for stat_boxplot.
2) In function 'calculate' in stat_boxplot, change:
if (length(unique(x)) > 1) width <- diff(range(x)) * 0.9 to width <- length(y);
In function 'reparameterise' in geom_boxplot, change:
df$width <- df$width %||%params$width %||% (resolution(df$x, FALSE) * 0.9) to df$width <- df$width*(resolution(df$x, FALSE) * 0.9)/max(df$width);
3) Source 'geom-boxplot.r' and 'stat-boxplot.r';
4) run. change the 'objname' to, say, 'boxplot2'. When calling geom_boxplot, I needed to explicitly specify the stat:
p <- ggplot(mtcars, aes(factor(cyl), mpg))
p + geom_boxplot(stat='boxplot2')
I think I did right for the first three steps, but for the last step, when I run p + geom_boxplot(stat='boxplot2'), I always get error: "Error: No stat called boxplot2"
Here is what I did for step4: objname <- "boxplot2" (I changed it for both geom_boxplot and stat_boxplot. is that correct?)
If I change to "boxplot2", do I also need to change the highlight part to "boxplot2"?
geom_boxplot <- function (mapping = NULL, data = NULL, stat = "boxplot", position = "dodge", .....
stat_boxplot<- function (mapping = NULL, data = NULL, geom = "boxplot", position = "dodge",
Thanks so much!!