Hey everyone,
I have a bit more of a general R question which I cant really figure out. I have a matrix of the type
[A] [B] [C] [1] 3 5 2 [2] 1 3 6 [3] 1 6 2
and a vector in the form
[A] [B] [C] [1] 2 4 7
What I am trying to get out is in this case 3 new columns attached to the initial matrix which would lets say go through all rows in column A and compare it to the value for [A] in the vector. If its higher than I would like to have a 1 in the new column, if lower a 0. And then for B and so on. In this example:
[A] [B] [C] [A.2][B.2][C.2] [1] 3 5 2 1 1 0 [2] 1 3 6 0 0 0 [3] 1 6 2 0 1 0
Anyone knows a good way to do this? I think I am getting too confused with multiple loops.
Thank you so much,
Ben