Skip to content

Commit 07f7364

Browse files
committed
geom_dotplot: Properly handle position comparison. Fixes #709
1 parent 442500d commit 07f7364

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

R/geom-dotplot.r

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,11 @@ GeomDotplot <- proto(Geom, {
132132
# Add back binaxis
133133
stat_params <- c(stat_params, binaxis=params$binaxis)
134134

135-
# If position=="stack" or position is position_stack() (the test is kind of complex),
136-
# tell them to use stackgroups=TRUE instead
137-
if (!is.null(position) && (position == "stack" || (is.proto(position) && position$objname == "stack")))
135+
# If identical(position, "stack") or position is position_stack() (the test
136+
# is kind of complex), tell them to use stackgroups=TRUE instead. Need to
137+
# use identical() instead of ==, because == will fail if object is
138+
# position_stack() or position_dodge()
139+
if (!is.null(position) && (identical(position, "stack") || (is.proto(position) && position$objname == "stack")))
138140
message("position=\"stack\" doesn't work properly with geom_dotplot. Use stackgroups=TRUE instead.")
139141

140142
if (params$stackgroups && params$method == "dotdensity" && params$binpositions == "bygroup")

0 commit comments

Comments
 (0)