An issue with geom_path & group aesthetic under ggplot2_0.9.3

387 views
Skip to first unread message

Bryan Hanson

unread,
Nov 20, 2012, 8:49:02 AM11/20/12
to ggplo...@googlegroups.com
Sorry, me again.  Trying to fix all my packages to work with ggplot2_0.9.3  Three of 4 fixed, this is the last one!

I have a function with this bit in it:

    if (method == "sem") {
        p <- p + stat_summary(fun.data = "seXy")
        if ((type == "connect") | (type == "anova")) {
            p <- p + stat_summary(fun.y = "mean", geom = "line")
                }
        }

The behavior in the earlier versions of ggplot2 was to first draw a pointrange using function seXy (basically std error of the mean).  That still works fine.  The second if statement would draw a line connecting the means in each level of each group (and I suppose it overdraws the mean point).  In ggplot2_0.9.3, I get this message:

geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?

The group aesthetic was set earlier in the function as:

    p <- ggplot(data, aes_string(x = fac1, y = res, color = fac2,
        group = fac2))

Now fac2 is most definitely not composed of one observation (test data below), although I suppose AFTER doing stat_summary one might say there is one observation per group, namely the mean.  Of course, that is the intent, so I don't think it should generate a warning.

This function is rxnNorm which is here if you need the full thing: github.com/bryanhanson/HandyStuff/tree/master/R  The example I am running is in github.com/bryanhanson/HandyStuff/blob/master/man/rxnNorm.Rd  (There are some deprecated warnings which I have fixed but not pushed to the repo).

Thanks, Bryan

str(testData)
'data.frame':    60 obs. of  4 variables:
 $ r  : num  5.45 5.53 4.03 5.12 5.22 ...
 $ f1 : Factor w/ 3 levels "L","M","H": 1 1 1 1 1 1 1 1 1 1 ...
 $ f2 : Factor w/ 2 levels "GMO","WT": 2 2 2 2 2 2 2 2 2 2 ...
 $ no1: num  5 5 5 5 5 5 5 5 5 5 ...

Winston Chang

unread,
Nov 29, 2012, 3:19:53 PM11/29/12
to Bryan Hanson, ggplot2-dev
Hi Bryan -

Did you see this behavior in 0.9.2.1? This message was added to the codebase a year ago (for version 0.9.0, I believe). Even though it has been there for a while, it is possible that other changes to 0.9.3-rc have exposed this bug for you.

-Winston

Bryan Hanson

unread,
Nov 29, 2012, 3:22:53 PM11/29/12
to Winston Chang, ggplot2-dev
I don't believe I tried it in 0.9.2.1 (it's hard for me to stay up to date during the semester, so I've been lurking mostly until the RC loomed large).  Thanks for looking at this!  Bryan
Reply all
Reply to author
Forward
0 new messages