Skip to content
Prev 333899 / 398506 Next

why change days of the week from a factor to an ordered factor?

On 02 Dec 2013, at 16:35 , Bert Gunter <gunter.berton at gene.com> wrote:

            
The coding is certainly clunky (the phrase about writing FORTRAN in any language springs to mind, only with SAS instead of FORTRAN):
This'll do:

dodgers$ordered_day_of_week <- factor(dodgers$ordered_day_of_week,
levels=c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"),
labels=c("Mon", "Tue", "Wed", "Thur", "Fri", "Sat", "Sun"))

And BTW, it doesn't (and didn't) create an ordered factor, just a factor with a different level ordering.