Skip to content

coerceAs may be doing factor coercion incorrectly #6140

@MichaelChirico

Description

@MichaelChirico

As seen in r-cmd-check-occasional:

test(10.16, coerceAs(1:2, factor(c("x","y"))), factor(c("x","y")), output="integer[integer] into integer[factor]")

When run in a locale where y sorts before x we get:

> x = coerceAs(1:2, factor(c("x", "y"))) 
First 2 of 2 (type 'integer'): 
[1] y x
Levels: y x
> y = factor(c("x", "y")) 
First 2 of 2 (type 'integer'): 
[1] x y
Levels: y x
2 string mismatches

I am not sure the intended behavior in this case, but that output does look potentially off to me. We can fix the test if the behavior is intentional, want to check with Jan first.

Metadata

Metadata

Assignees

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