vendredi 19 février 2021

How can I loop through a data matrix and compute on select rows?

I have the following data matrix called matrix1:

  [,1] [,2] [,3] [,4] [,5] [,6]
A    1    1    4    1   19   15
C    2    1    1    1    1    1
G    1   19   15   19    1    4
T   18    1    2    1    1    2

For rows A and T, I would like all the values divided by 0.3. For rows C and G I would like all the values divided by 0.2. I would then like the new values returned in a matrix called matrix2.

Is there a way to loop through this matrix or use a conditional statement to have the proper rows get divided by the proper value? Please let me know!!

Aucun commentaire:

Enregistrer un commentaire