How to Extract Rows from multiple dataframes with row.names

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)

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 :slightly_smiling_face:

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

YW - If this solves your issue, please mark my answer as solution :+1:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.