I got one for you guys tonight!!!
I have a 30,000 x 30,000 data frame. I have a list of strings which may, or may not match some of the rownames in the df.
I need to test the list of strings I have to find out whether or not they are in the df or not. Here is a small reprex example:
df <- data.frame(
one = c(2,1,2,0,0,1),
two = c(4,5,3,0,1,3),
three = c(1,0,2,0,7,4),
four = c(3,2,1,0,0,0)
)
row.names(df) <- c('mm1','mm2','mm3', 'GC1', 'GC2', 'GC3')
df
one two three four
mm1 2 4 1 3
mm2 1 5 0 2
mm3 2 3 2 1
GC1 0 0 0 0
GC2 0 1 7 0
GC3 1 3 4 0
rowname.list <- c("mm2", "mm3", "mm7", "GC2", "GC8")
Ideally I would like some kind of output where I can easily look at the list of rownames and see if there is a row with that name in the matrix. Something like this maybe:
y
mm2 1
mm3 1
mm7 0
GC2 1
GC8 0
But anything would work. Thanks in advance I owe you guys alot!