[Rd] pmin/pmax issue with ordered factors
Erwan Le Pennec
lepennec at cmap.polytechnique.fr
Wed Nov 30 11:05:43 CET 2016
Dear all,
pmin/pmax used to work with ordered factors but fail now since this
summer when those functions have tried to handle more cases.
A simple way to trigger the issue is:
> min(ordered(c(1,5,6)))
[1] 1
Levels: 1 < 5 < 6
> pmin(ordered(c(1,5,6)), ordered(c(1,5,6)))
Error in `mostattributes<-`(`*tmp*`, value = attributes(elts[[1L]])) :
adding class "factor" to an invalid object
A simple fix is to explicitly test for the ordered class and use the
internal method in that case as proposed in the attached patch.
Yours,
Erwan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-patch
Size: 1016 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20161130/71dc22b6/attachment.bin>
More information about the R-devel
mailing list