Re: [Rd] Undesirable behaviour of base::factor

2024-05-24 Thread peter dalgaard
I think this is a "Doctor, it hurts when I do this" issue. The root of it is that as.character() behaves differently on integers and floating values. > factor(10) [1] 1e+05 Levels: 1e+05 > factor(10,levels=10) [1] 1e+05 Levels: 1e+05 > factor(10,levels=10:10) [1] > f

[Rd] Undesirable behaviour of base::factor

2024-05-23 Thread Andrew Gustar
This thread on stackoverflow illustrates the problem... https://stackoverflow.com/questions/78523612/r-factor-from-numeric-vector-drops-every-100-000th-element-from-its-levels The issue is that factor(), applied to numeric values, uses as.character(), which converts numbers to character strings