Sort a named list in R

后端 未结 2 1035
鱼传尺愫
鱼传尺愫 2021-01-01 19:04

I have a named list of term frequencies,

> list
$`in the`
[1] 67504

$`to the`
[1] 36666

$`of the`
[1] 79665

$`on the`
[1] 31261

$`to be`
[1] 25862

$`         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-01 19:58

    If the list is large and involves large objects, would it be better to just use names?

     lst = lst[order(names(lst))]
    

提交回复
热议问题