I have a matrix of which I want to edit one of the columns based on another of the columns. The column I want to edit has numeric values and the reference column has string values.
I have a matrix that looks like this:
M = matrix(c(1,4,7,6,5,a,b,c,a,b),5,2) 1 a 4 b 7 c 6 a 5 b And I want to multiply by a factor the rows where the second column has the "a" value, to get a matrix like this (for example by multiplying by 2):
2 a 4 b 7 c 12 a 5 b