r - Re-ordering factor levels in data frame -
this question has answer here:
i have data.frame shown below:
task measure right m1 left m2 m3 down m4 front m5 m6 . . .
the task column takes 6 different values, treated factors, , ordered r as: "back", "down", "front", "left", "right", "up".
how ever, need them ordered as: "up", "down", "left", "right", "front", "back". when use data in ggplot, related tasks (such "up" , "down") plotted next each other.
how can change ordering of levels of factor "task"?
assuming dataframe mydf:
mydf$task <- factor(mydf$task, levels = c("up", "down", "left", "right", "front", "back"))
Comments
Post a Comment