I have a small data set like this:
Wday av_obs
Tue 385
Thu 321
Fri 440
Wed 398
Sat 419
Mon 312
Sun 547
Wday is a character variable that indicates the day of a week and av_obs is a numeric variable showing the average number of observations made on that weekday. To plot this relationship I would like to turn the Wday variable into a factor variable with the levels according to a "normal" week. (like this: Mon < Tue < Wed < Thu < Fri < Sat < Sun)
I know about the as.factor function, but I think it doesn't allow me to decide the levels of the factor myself. It just copies the order from the data frame.
If you know a quick and easy approach to this, let me know & thanks in advance!
x$Wday <- factor(x$Wday, c("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"))
– GKi