powered by
This is useful when the levels of an ordered factor are actually cyclical, with different conventions on the starting point.
fct_shift(f, n = 1L)
A factor.
Positive values shift to the left; negative values shift to the right.
# NOT RUN { x <- factor( c("Mon", "Tue", "Wed"), levels = c("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"), ordered = TRUE ) x fct_shift(x) fct_shift(x, 2) fct_shift(x, -1) # }
Run the code above in your browser using DataLab