Hi. I have a table A with 5 columns, the first three columns are categorical and the other two are numbers. The table contains 198 riws and is like this:
TumoSize NodalStatus Grading ER HER2
pT1b pN0 G2 0 0
pT2 pN3 G3 90 3
pT2 p1mi G2 55 2
…
Now, I have to filter this table per raw and assign a score of:
- 2 when TumorSize is equal to pT2 or pT3 or pT4
- 1 when NodalStatus is equal to pN2 or N3
- 1 when Grading is equal to G3
- 1 when ER is <70
- 1 when HER2 is equal to 0 or 1 or 2
At the end, I have to sum all this score per raw and then divide in three groups, according to the score (score between 0-2; score 3 or 4 and score 5-7)
My code, that doesn't work, is:
for r = 1:size(A,1) for c = 1:size(A,2) g = A(r,c); score = 0; if g == 'pT2' || g == 'pT3' || g == 'pT4' || g == 'pN2' || g == 'pN3' score = 2; else if g == 'G3' || g >= 0 && g<70 || g == 0 || g == 1 || g == 2 score = 1; else score = 0 end B(r,c) = score end endendtotal_score = sum(B,2) %sum score
firstgroup = sum(total_score == 0 | total_score == 1 | total_score == 2)secondgroup = sum(total_score == 3 | total_score == 4)thirdgroup = sum(total_score == 5 | total_score == 6 | total_score == 7)
it doesn't work!!! Help me please 🙂
thank you in advance
Best Answer