Ordering the axis labels in geom_tile

后端 未结 5 1121
离开以前
离开以前 2020-12-28 09:31

I have a data frame containing order data for each of 20+ products from each of 20+ countries. I have put it in a highlight table using ggplot2 with code simila

5条回答
  •  感情败类
    2020-12-28 10:05

    Maybe a little bit late,

    with(mymelt,factor(variable,levels = rev(sort(unique(variable)))))
    

    this function doesn't order, because you are ordering "variable" that has no order (it's an unordered factor).

    You should transform first the variable to a character, with the as.character function, like so:

    with(mymelt,factor(variable,levels = rev(sort(unique(as.character(variable))))))
    

提交回复
热议问题