0

I have 2 dataframe objects with common transcript names. The names are out of order for each other, and as such I am trying to index into them and pull out the rows based off from this first column of transcript names to organize the data. I want to retain all of the different values in the other columns, but just reorder the data based off from the indices. I am trying to do this in R.

In MATLAB I can do this by using intersect to find the indices.

  • 6
    Not clear without a small reproducible example and expected output – akrun Aug 30 '19 at 17:24
  • 2
    Please make this question *reproducible*. This includes sample code (including listing non-base R packages), sample *unambiguous* data (e.g., `dput(head(x))` or `data.frame(x=...,y=...)`), and expected output. Refs: https://stackoverflow.com/questions/5963269, https://stackoverflow.com/help/mcve, and https://stackoverflow.com/tags/r/info. – r2evans Aug 30 '19 at 17:30

1 Answers1

0

Sounds like you want to merge on transcript name. As in df.new <- merge(df.1,df.2,by="transcript.name"). This will merge the observations (rows) that are common to both data frames. If you want to retain all the observations from the first data frame (df.1), even if they're not in df.2, then include all.x=TRUE.

TJ87
  • 404
  • 1
  • 3
  • 13