Specifing order of lattice plot panels

前端 未结 2 1079
轮回少年
轮回少年 2021-01-22 02:42

I have looked at the two similar questions on this topic but do not find the answer I\'m looking for in either of the two. The as.table function alters the alphabetic sequence f

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-22 03:22

    There are a couple of points here.

    First is that in R things like the order of factor levels are considered to be a property or attribute of the data rather than a property of the graph/analysis. Because of that there is not generally arguments in the plotting or analysis functions for specifying the order, rather you specify that order in the data object itself, then all plots and analyses use that order.

    To change the order you can specify the desired order using the factor function, or you can use functions like relevel and reorder to change the order of the levels of a factor. If you want the levels to be in the same order that they appear in the data then the unique function works well. For sorting with characters and numbers mixed the mixedsort function in the gtools package can be useful.

提交回复
热议问题