I want to create a function that, given a string, iterates over the rownames of a dataframe, and, in case they´re equal, stores its value. Here I give a toy example:
Places  x1  x2  x3  x4  x5  
A       0   5   0   0   0
B       0   0   0   23  0
C       23  0   0   0   0
D       8   0   0   0   0
I would like something like this:
sequence <- ("ACF")
function(sequence)
>> 0   5   0   0   0   23  0   0   0   0
"A" is in the rownames of the dataframe, and so is "C", so the function stock their values in a new vector.
codification <- function(sequence) {
  bits <- vector()
  for (i in sequence){
    if (any(rownames(dataframe)==i)){
      bits <- bits.append()
    }
  }
}
I think the rest of the function is working, but I couldnt find anything to write in bits <- bits.append() to storage the values. Any help would be really appreciated.
 
    