Skip to content
Prev 31917 / 63424 Next

Match .3 in a sequence

Wacek Kusnierczyk wrote:
as a corollary, the warning printed when comparing elements of a factor
is misleading:

    f = factor(1:2)
    f[1] < f[2]
    # [1] NA
    # Warning message:
    # In Ops.factor(f[1], f[2]) : < not meaningful for factors

    g = as.ordered(f)
    is.factor(g)
    # TRUE
    g[1] < g[2]
    # TRUE


< *is* meaningful for factors, though not for unordered ones.  the
warning is generated in Ops.factor, src/library/base/all.R:7162, and
with my limited knowledge of the r internals i can't judge how easy it
is to fix the problem.

vQ