Reputation: 51
I have a data.frame
which I want to subset based on a list of certain IDs. I want to extract all the rows from this data.frame
which have the same ID as my variable "genes". So far I have:
Final_Genes <- subset(Merged_Results,Merged_Results$Entrez.ID == genes, select = c(1:8))
but this produces an error,
Warning messages:
1: In is.na(e1) | is.na(e2) :
longer object length is not a multiple of shorter object length
2: In `==.default`(Merged_Results$Entrez.ID, genes) :
longer object length is not a multiple of shorter object length
Which to be honest I don't understand.
Upvotes: 1
Views: 5347
Reputation: 11
Just substitute == with %in% and it worked for me, even with the subset command.
Upvotes: 1
Reputation: 12664
Try
Final_Genes<-Merged_Results[Merged_Results$Entrez.ID==genes,1:8]
This assumes that "genes" is that same as a single Entrez.ID. If genes is acutally a vector of several "Entrez.ID"s you could replace the ==
with %in%
Upvotes: 5