I'm trying to clean up a data sheet that has multiple test results. We're considering a positive from any of the results to mean the person is positive. So I'm trying to create a code where if any of the test results are positive, then the diagnosis is positive. If there are no positives and at least one negative, then the diagnosis is negative (ex. Patients 4, 5 and 6). I also want to omit rows where there are no results (ie. NA) for all of the rows (ex. Patient 8). Can anyone help me with this? I tried this ifelse
statement, but it's not working
practice$Diagnosis = ifelse((testresult_1 == "1"|testresult_2 == "1"|testresult_3 == "1"), "Positive", "Negative")
Patient ID testresult_1 testresult_2 testresult_3 Diagnosis
1 Positive Negative Negative Positive
2 Positive Positive Negative Positive
3 Negative Negative Positive Positive
4 Negative Negative Negative Negative
5 Negative Negative NA Negative
6 Negative NA NA Negative
7 Positive NA NA Positive
8 NA NA NA NA
Aucun commentaire:
Enregistrer un commentaire