Skip to content

PositionStack (and others) expects a numeric, non factor, "group" #6838

@rikivillalba

Description

@rikivillalba

PositionStack and similar classes that use collide() and collide2 to sort the data expects "group" to be numeric, not factor.
Some Stats may create a "factor" group column, though not those which might be stacked (i.e. StatContour), the problem is relevant for custom Stat extensions that might update group.
The problem arises because for reverse = TRUE, the "collide" functions use order(..., -data$group) instead of order(..., data$group, decreasing = TRUE), as "-" is not meaningful for factors.

ord <- order(data$xmin, -data$group)

ggplot(faithfuld, aes(waiting, eruptions, z = density)) + 
  geom_contour(position = "stack")
# warning "-" no meaningful for factors
```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions