1

I have 48 data frames in my global environment, and I would like to merge them accordingly to column 1 (of each one). All data frames have only 1 column and are in this style:

df1 <- data.frame("Genes" = c("EGF", "FGF", "IGF"))

df2 <- data.frame("Genes" = c("Myo6", "NRP2", "P23"))

I tried converting them into a list, but then, what I wanted to merge was level 2 of each one so it turned complicated.

Expected final result:

df3 <- data.frame("Genes" = c("EGF", "FGF", "IGF", "Myo6", "NRP2", "P23"))

If anyone could help, it'd be wonderful Thanks

1 Answers1

1

Here, is one option with mget to load all the object with names that start with 'ZEB' followed by digits into a list, unlist the list and create the data.frame

out <- data.frame(Genes = unlist(unname(mget(ls(pattern = '^ZEB[1-2]')))))
akrun
  • 874,273
  • 37
  • 540
  • 662