I have a list of names, and a data.frame with many different columns. How can I retrieve rows in the data frame that their row.name is one of the names in my list?
For example if the row.names in my data frame has many rows, including TC09001536.hg.1
, TC03002852.hg.1
, and TC18000664.hg.1
names, which are saved in list called Top.list
.
Assuming my data frame is called df then I tried:
test <- df[grep(Top.list, df$cluster_id),]
to look within cluster_id
column and if matches the names in my list then give me whole rows.