On Tue, Mar 17, 2009 at 10:15:39AM +0100, Wacek Kusnierczyk wrote: ... > there's one more curiosity about factors, in particular, ordered factors: > > ord <- as.ordered(nums); ord > # [1] 0.300000000000000 0.3 0.3 > 0.300000000000000 > # Levels: 0.300000000000000 < 0.3 < 0.3 < 0.300000000000000 > > ord[1] < ord[4] > # TRUE > ord[1] == ord[4] > # TRUE ...
The following workaround should help in most cases. nums <- (.3 + 2e-16 * c(-2,-1,1,2)) nums # [1] 0.3 0.3 0.3 0.3 nums <- signif(nums, digits=15) as.ordered(nums) # Levels: 0.3 as.factor(nums) # Levels: 0.3 Petr. ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel