krnl90
March 8, 2020, 7:40pm
1
Hello,
So i Have 4 different data frames and i want to find common values between them and want to extract those rows all in all, So i think using subset before intersect should work if i am not wrong.
Any suggestions how advanced subsetting works?
Newfunction<- function(A,B,C,D) {
Matrix_1 <- intersect(row.names(A),row.names(B))
Matrix_2 <- intersect(row.names(C),row.names(D))
Combined_matrix <- intersect(Matrix_1,Matrix_2)
return(Combined_matrix)
}
Newfunction (Healthy_1, Healthy_2, Healthy_3, Aggr_data)
Leon
March 8, 2020, 8:24pm
2
Hi @krnl90
Take a look at this:
library("dplyr")
set.seed(435398)
d1 = tibble(id = sample(LETTERS[1:10], 5),
val = rnorm(5))
d2 = tibble(id = sample(LETTERS[1:10], 5),
val = rnorm(5))
d3 = tibble(id = sample(LETTERS[1:10], 5),
val = rnorm(5))
d1 %>% inner_join(d2, by = "id") %>% inner_join(d3, by = "id")
d1 %>% full_join(d2, by = "id") %>% full_join(d3, by = "id") %>% drop_na
Hope it helps
krnl90
March 9, 2020, 6:28pm
3
Thanks leon. I am working on that. I will let you know if this works or not. But thank you so much for your help.
Best
Leon
March 10, 2020, 9:02am
4
YW - If this solves your issue, please mark my answer as solution
system
Closed
March 31, 2020, 9:02am
5
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.