Skip to content

Some minor (but breaking) suggestions for categorize() #709

Open

Description

@mattansb
  1. Current behavior is to return an integer vector. To be consistent with cut(), and to be safer to use, I think this function should return by default a factor - possible an ordered factor.
    • also I think we can drop the lowest argument?
  2. The breaks argument in R is usually used to provide the breaking values - here if those are done manually, they are sent to split instead.
  3. Rename split to method?
    1. We should add a right = TRUE argument, like with cut().

Activity

  1. strengejacke commented on Sep 8, 2026

    @strengejacke
    Member

    We should add a right = TRUE argument, like with cut().

    The right argument is handled like this: cut(..., right = identical(breaks, "inclusive")).

    Rename split to method?

    split currently also accept a numeric vector with values that define the splits, thus, I'd say a method argument is not fully appropriate?

    Current behavior is to return an integer vector. To be consistent with cut(), and to be safer to use, I think this function should return by default a factor - possible an ordered factor.

    Not for factors, only for numerics. When you use the labels argument, a factor is always returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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