I have two lists comprising of several dataframes each, but in different order. List 1 has gene expression values and list 2 has gene membership in clusters. I would like to perform an inner join based on the item names, but how can I avoid doing it without having to specifically run each inner join separately?
lst1 <- list(Df1, Df2, Df3)
lst2 <- list(Df2, Df3, Df1)
Code I want to avoid:
gene_cluster[["Df1"]] <- lst1[["Df1"]] %>%
inner_join(lst2[["Df1"]] , by = "gene_name")
gene_cluster[["Df2"]] <- lst1[["Df2"]] %>%
inner_join(lst2[["Df2"]] , by = "gene_name")
gene_cluster[["Df3"]] <- lst1[["Df3"]] %>%
inner_join(lst2[["Df3"]] , by = "gene_name")
Thanks!