Reputation: 83
I've got about 30 datatables. Now I want to find overlaps in the first column in some of the tables and extract them. The result should be a table with the overlaps in the first column from more than two datatables. Here's an example:
Table1:
Gen Estimate Std. Error p-Wert
1007_s_at -0.159699 0.07834 0.04265
1053_at -0.174647 0.064535 0.0098976
121_at 0.1765678 0.05116854 0.0000657
Table2:
Gen Estimate Std. Error p-Wert
1494_f_at 0.2222467 0.0553653 0.0075838
121_at 0.873683 0.00898737 0.0088378
1316_at 0.098764 0.098456 0.048899
1007_s_at 0.89723 0.5675389 0.00007865
Table3:
Gen Estimate Std.Error p-Wert
1007_s_at 0.0864567 0.8931278 0.005542
121_at 0.2378590 0.0236586 0.00005667
1494_f_at 0.4597023 0.9875357 0.0091234
The result should be:
Gen
1007_s_at
121_at
I tried the foverlaps function, but that's only for two datatables. So it didn't work.
I hope someone could help. Thanks!
Upvotes: 1
Views: 85
Reputation: 2469
I think for this you want to use set operations.
This should work:
dat1 <- data.frame(gen = c("aaaaa", "1494_f_at", "1111", "!!!!"), stringsAsFactors = FALSE)
dat2 <- data.frame(gen = c("1494_f_at", "cccccc", "!!!!","999"), stringsAsFactors = FALSE)
dat3 <- data.frame(gen = c( "!!!!","1494_f_at", "999", "dddddd"), stringsAsFactors = FALSE)
intersect(intersect(dat1[,1], dat2[,1]), dat3[,1])
Upvotes: 1