gpt4 book ai didi

r - 订购 list ,命令不起作用

转载 作者:行者123 更新时间:2023-12-04 09:31:37 26 4
gpt4 key购买 nike

我有以下列表:

我的 list

[[1]]
[1] 11
[[2]]
[1] 9
[[3]]
[1]
10

我想对它进行排序。我试过了

sort(mylist)

Error: mylist must be atomic

sort.list(mylist)

Error in sort.list(mylist) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list?

order(mylist)

Error in order(mylist) : unimplemented type 'list' in 'orderVector1'

最佳答案

我们需要ordervector 上.在这里,假设 list每个元素的长度只有 1,unlist “我的列表”,ordervector 上然后使用它

mylist[order(unlist(mylist))]
#[[1]]
#[1] 9

#[[2]]
#[1] 10

#[[3]]
#[1] 11

关于r - 订购 list ,命令不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42830072/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com