Specifing order of lattice plot panels

前端 未结 2 1078
轮回少年
轮回少年 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:03

    You need to specify the levels of that factor variable in the sequence you expect. The default is lexigraphic as you noticed:

    xyplot(as.d$quant ~ as.d$sampdate | factor( as.d$site, 
                                                levels=1:length(unique(as.d$site))) , 
             ylim=range(as.d$quant),   xlim=range(as.d$sampdate), 
             main='Arsenic By Time', ylab='Concentration (mg/L)', xlab='Time')
    

    Based on how the question currently stands, you might need:

    require(gtools)
    xyplot(as.d$quant ~ as.d$sampdate | factor( as.d$site, 
                                      levels=mixedsort( as.character(unique(as.d$site)) ) ) , 
             ylim=range(as.d$quant),   xlim=range(as.d$sampdate), 
             main='Arsenic By Time', ylab='Concentration (mg/L)', xlab='Time')
    

提交回复
热议问题