median_hilow with stat_summary seems broken

147 views
Skip to first unread message

Harlan Harris

unread,
Apr 20, 2011, 11:27:53 AM4/20/11
to ggplot2
Hi all,

A script I wrote a while ago seems to be broken under the versions of
packages I'm currently using. It seems to be an issue with the
median_hilow function that gets passed to stat_summary. I get the
following error:

Error: geom_crossbar requires the following missing aesthetics: ymax

And diving into things a bit I get:

> summary(mydata)
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
0.000 5.000 8.000 9.508 12.000 80.000 12.000

> median_hilow(mydata, conf.int=.8)
y y ymin
1 8 3 17

That seems weird. I would have expected that function to return values
of y, ymin, and ymax.

In debug:
debug: {
try_require("Hmisc")
result <- safe.call(fun, list(x = x, ...))
rename(data.frame(t(result)), c(Median = "y", Mean = "y",
Lower = "ymin", Upper = "ymax"))
}

> result
Median Lower Upper
8 3 17

Ah, it appears as if it's pulling the version of rename() from plyr.
So, namespace issue maybe?

Versions:
R version 2.12.2 (2011-02-25)
x86_64-apple-darwin9.8.0
ggplot2 0.8.9
Hmisc 3.8-3
plyr 1.5.1
reshape

Any thoughts for fixes or workarounds? Upgrading to R 2.13.0 is not an
option...

-Harlan

Harlan Harris

unread,
Apr 20, 2011, 11:29:16 AM4/20/11
to ggplot2
Er, Google Groups sent this before I was ready... One tiny change:

> reshape 0.8.4

Brian Diggs

unread,
Apr 20, 2011, 4:11:03 PM4/20/11
to ggp...@googlegroups.com

I thought I had an answer until I saw you already had version 1.5.1 of
plyr. That fixed a bug in plyr::rename which could have caused it.

I can not reproduce the problem myself:

library("ggplot2")
library("Hmisc")

set.seed(42)
mydata <- sample(20, 100, replace=TRUE)

median_hilow(mydata, conf.int=0.8)
median_hilow(mydata)


On both 2.12.2 and 2.13.0 (sessionInfo below, but same version numbers
of packages that you list), I get:

> median_hilow(mydata, conf.int=0.8)
y ymin ymax
1 11.5 2 19
> median_hilow(mydata)
y ymin ymax
1 11.5 1 20


Can you give a fully reproducible example with sessionInfo()?


R version 2.12.2 (2011-02-25)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] splines grid stats graphics grDevices utils datasets
[8] methods base

other attached packages:
[1] Hmisc_3.8-3 survival_2.36-5 ggplot2_0.8.9 proto_0.3-9.1
[5] reshape_0.8.4 plyr_1.5.1

loaded via a namespace (and not attached):
[1] cluster_1.13.3 lattice_0.19-23


R version 2.13.0 (2011-04-13)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] splines grid stats graphics grDevices utils datasets
[8] methods base

other attached packages:
[1] Hmisc_3.8-3 survival_2.36-8 ggplot2_0.8.9 proto_0.3-9.1
[5] reshape_0.8.4 plyr_1.5.1

loaded via a namespace (and not attached):
[1] cluster_1.13.3 lattice_0.19-23


--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University

Reply all
Reply to author
Forward
0 new messages