0

I'm fairly new to coding and hope I can get some help here on StackOverflow. I have a large dataframe with 16871 observations and 11 variables. I have another txt file with a list of 1118. I'd like to create a new dataset by selecting from the 16871, the exact 1118 rownames.

Large Dataframe

List of 1118 genes

The line I'm using to subset it is:

JustTTXGenes<-SELECTED_ALEX_BRUSEQ_JULY2018[row.names(SELECTED_ALEX_BRUSEQ_JULY2018) %in% TTXResponseGenes,]

But for some reason, JustTTXGenes is coming up with 0 observations and 11 variables. Can someone help me?

Sylvox
  • 1
  • 1
  • 1
    I think you should use `SELECTED_ALEX_BRUSEQ_JULY2018$Geneid` instead of `row.names(SELECTED_ALEX_BRUSEQ_JULY2018)`. Or with `dplyr`: `SELECTED_ALEX_BRUSEQ_JULY2018 %>% inner_join(TTXResponseGenes, by = "Geneid")`. – Martin Gal Jul 22 '21 at 22:28
  • Thank you for your response Martin. JustTTXGenes <- SELECTED_ALEX_BRUSEQ_JULY2018[SELECTED_ALEX_BRUSEQ_JULY2018$Geneid %in% TTXResponseGenes,] Is this what you meant? – Sylvox Jul 22 '21 at 22:40
  • Is `TTXResponseGenes` a dataframe or a `vector`? – Jason Mathews Jul 22 '21 at 22:59
  • TTXResponseGenes is a vector. – Sylvox Jul 23 '21 at 00:34
  • It would be easier to help if you create a small reproducible example along with expected output. Read about [how to give a reproducible example](http://stackoverflow.com/questions/5963269). Images are not the right way to share data/code. – Ronak Shah Jul 23 '21 at 03:59

0 Answers0