Re: [R] ggplot: combining geom's in function

2015-10-24 Thread Jeff Newmiller
If you want to use the lattice way of doing things, why are you using ggplot? `+` is defined for the output of ggplot (class "waiver") on the left, and the output of a layer function ("proto") on the right. The design of ggplot assumes left-to-right evaluation, which your first attempt failed

[R] ggplot: combining geom's in function

2015-10-23 Thread sbihorel
Hi, Next adventure into my journey from lattice to ggplot: I would like to create a custom generic function that combines multiple existing geom's in order to reproduce what the lattice panel.xyplot function does based on the type argument (ie, plotting points only for type='p', plotting

Re: [R] ggplot: combining geom's in function

2015-10-23 Thread Erich Neuwirth
I often look for examples in http://www.cookbook-r.com/Graphs/ > On 23 Oct 2015, at 18:27, Jeff Newmiller wrote: > > Have you looked at the qplot function in the ggplot2 package? >

Re: [R] ggplot: combining geom's in function

2015-10-23 Thread Jeff Newmiller
Have you looked at the qplot function in the ggplot2 package? --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go...

Re: [R] ggplot: combining geom's in function

2015-10-23 Thread sbihorel
Hi Thanks for the suggestion. Unfortunately, the qplot function would work nicely if only I did not need to combine its output with other geom called before... A simple example using the data previously described: ggplot(data, aes(x,y,group=g)) + geom_blank() +

Re: [R] ggplot: combining geom's in function

2015-10-23 Thread sbihorel
Following up on my previous reply, this following would work but would not behave like a geom function: geom_xyplot <- function (gplot, mapping = NULL, data = NULL, stat = "identity", position = "identity", na.rm = FALSE, type = 'p', ...) { if (any(type=='p')){