在DataFrame R / Compinatorics中找到可行的组合
我有以下挑战: 具有218个观测值(行)和218个变量(COLS)的数据框架。 值是真或错误。 现在,我需要找到至少2行出现(true)的变量(col)组合。
以下是一个示例:
data <- data.frame(matrix(FALSE, nrow = 3, ncol = 5))
colnames(data) = paste("item_", 1:5, sep = "")
rownames(data) = paste("Process_", 1:3, sep = "")
data["Process_1",c("item_1","item_2","item_3")] = TRUE
data["Process_2",c("item_2","item_3")] = TRUE
data["Process_3",c("item_1","item_2","item_3","item_4","item_5")] = TRUE
在示例中,可行组合(或发现的目标)是以下组合:
c1:item1,item2,item3 c2:item2
c2:item3
c3:item3 c3:item1,item2
c4:item2 c4:item1,item1,item3
谢谢你,非常感谢您回答或提示很多:)
欢呼
I have the following challenge:
dataframe with 218 observations (rows) and 218 variables (cols).
The values are either TRUE or FALSE.
Now i need to find combinations of variables (cols) that appear (TRUE) in at least 2 rows.
Here is a little example:
data <- data.frame(matrix(FALSE, nrow = 3, ncol = 5))
colnames(data) = paste("item_", 1:5, sep = "")
rownames(data) = paste("Process_", 1:3, sep = "")
data["Process_1",c("item_1","item_2","item_3")] = TRUE
data["Process_2",c("item_2","item_3")] = TRUE
data["Process_3",c("item_1","item_2","item_3","item_4","item_5")] = TRUE
For the example the feasible combinations (or the goal to find out) are the following combinations:
c1: item1,item2,item3
c2: item2,item3
c3: item1, item2
c4: item1, item3
Thank you very much for an answer or a hint :)
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)