gpt4 book ai didi

r - 多个工会

转载 作者:行者123 更新时间:2023-12-04 02:51:04 25 4
gpt4 key购买 nike

我试图在几个列表上做联合(这些实际上是 GRanges 对象而不是整数列表,但原理是一样的),基本上是一个大联合。

x<-sort(sample(1:20, 9))
y<-sort(sample(10:30, 9))
z<-sort(sample(20:40, 9))
mylists<-c("x","y","z")
emptyList<-list()
sapply(mylists,FUN=function(x){emptyList<-union(emptyList,get(x))})

那只是返回列表内容。
我需要相当于
union(x,union(y,z))
[1] 2 3 5 6 7 10 13 15 20 14 19 21 24 27 28 29 26 31 36 39

但以可扩展且非“显式变量”的形式编写

最佳答案

与 GRanges 一起工作的不一定是内存高效的范例是

Reduce(union, list(x, y, z))

参数也可能是 GRangesList(x, y, z)对于 x 的适当值等等。

关于r - 多个工会,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5516070/

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