I am trying to search through a data.frame and get a value in the same row, a few columns away. I have input the file but what remains is to search for the the variable. In that, I do not know how to begin. In the small sample of the table, that I have included below, I need to search through and find a value (which is stored as a variable) in id (which will be unique) and return that value to a new variable, which could be used in a graph title.
id,cov
2A,50
2b,3
8f,12
I imagine I might have to use something like this:
comparison <- compare(s,search,allowAll=TRUE)
but I was hoping someone had some suggestions or guidance on the matter so as to limit my blundering
#Got the cov column
m<-data.frame(MNS=c(mns$cov))
head(m)
MNS
1 50
2 3
3 12
#Got the id column
s<-data.frame(SPL=c(mns$id))
#The value that I would like to search for
search<-'2b'
head(search)
[1] "2b"
#My attempt to find it
see<-mns[mns$id=='search',]
head(see)
[1] sample_id
[2] meanCov
<0 rows> (or 0-length row.names)
I think you are after something like this
Updated with the new comments
or