Skip to content

vec_c (i.e. also bind_rows) takes the prefix of the first unit rather than auto_scaling (unlike c() which autoscales) #2

@sebkopf

Description

@sebkopf

As far as I can tell there is no way to have vec_c() return autoscaled units because:

  • let's say we're combining x and y
  • vctrs::vec_ptype2 finds the common type between x and y
  • vctrs::vec_cast() casts each x and y independently to the common type determined by vec_ptype2
  • here's the rub: vec_ptype2 DOES not get the whole vectors x and y with the data in it but only the object types (essentially whatever vec_slice(x, 0L) returns)
  • here's the problem then: to determine the ideal auto-scaling for a combined x and y we'd need to have the data so we can calculate the median and decide on the ideal prefix for the combined vector, neither vec_ptype2 nor vec_cast has all the information (vec_ptype2 has the units but not the actual numbers, vec_cast only has the units of one at a time) to do this correctly so I do not see any way for vec_c()/bind_rows to autoscale
  • result: vec_c() can only scale to the ideal prefix of one of the vectors (calculations are correct but autoscaling doesn't work)

Question then: currently c() does autoscale (because it has all the info and thus can) but should this be it's behaviour?? (leads to vec_c() and c() scaling differently)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwontfixThis will not be worked on

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions