x <- c("a", NA, "b")
x <- fact(x)
str(x) # NA is 3L
y <- x
class(y) <- c("ordered", class(y))
max(y)
max(y, na.rm = TRUE) # returns NA -- bad
# as_ordered() removes the NA level
x <- as_ordered(x)
str(x)
max(x, na.rm = TRUE) # returns b -- correct
Run the code above in your browser using DataLab