Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 从翻转对象中提取交点列表_R_Set Intersection_Set Operations_Upsetr - Fatal编程技术网

R 从翻转对象中提取交点列表

R 从翻转对象中提取交点列表,r,set-intersection,set-operations,upsetr,R,Set Intersection,Set Operations,Upsetr,我正在与UpSetR进行一些比较,我想保存落入每个交叉点的元素列表。这可能吗?我到处都找不到它 手动操作(许多列表)会非常繁琐,而且由于它们是经过计算的,因此无法保存它们是令人沮丧的没有现成的upSetR函数用于此操作。但是,可以提取它: library(UpSetR) # Example input as list, expected output is 1 and 5: listInput <- list(one = c(1, 2, 3, 5, 7, 8, 11, 12, 13),

我正在与UpSetR进行一些比较,我想保存落入每个交叉点的元素列表。这可能吗?我到处都找不到它

手动操作(许多列表)会非常繁琐,而且由于它们是经过计算的,因此无法保存它们是令人沮丧的

没有现成的upSetR函数用于此操作。但是,可以提取它:

library(UpSetR)

# Example input as list, expected output is 1 and 5:
listInput <- list(one = c(1, 2, 3, 5, 7, 8, 11, 12, 13), 
                  two = c(1, 2, 4, 5, 10),
                  three = c(1, 5, 6, 7, 8, 9, 10, 12, 13))
我们可以使用Reduce:


也许这篇文章能帮上忙-你不是定义绘图的人吗?@zx8754谢谢,它似乎很有帮助,我在dplyr中做这件事时遇到了麻烦:)我只是很惊讶,没有一个选项可以从打乱()输出来做这件事,我不希望它是复杂的实现,反正所有的交点都是计算出来的。。我想,只需要一个把手就可以把它们取出来了。@Abdessabour Mtk我不确定我是否明白你的意思,但是在upsetR中,你定义了你想要比较的集合,所有的交集都在引擎盖下完成,并直接绘制。。这就是为什么它很方便:)如果您使用
x,您可以随时在以下位置请求“功能请求”:
x <- upset(fromList(listInput))
x$New_data
#    one two three
# 1    1   1     1
# 2    1   1     0
# 3    1   0     0
# 4    1   1     1
# 5    1   0     1
# 6    1   0     1
# 7    1   0     0
# 8    1   0     1
# 9    1   0     1
# 10   0   1     0
# 11   0   1     1
# 12   0   0     1
# 13   0   0     1
x1 <- unlist(listInput, use.names = FALSE)
x1 <- x1[ !duplicated(x1) ]
x1
# [1]  1  2  3  5  7  8 11 12 13  4 10  6  9
x1[ rowSums(x$New_data) == 3 ]
# [1] 1 5
Reduce(intersect, listInput)
# [1] 1 5