lundi 5 octobre 2020

if_else double criteria condition in R

PID D1  D2  D3
123 0   0   0
234 0   0   1
456 0   1   0
666 0   1   1
555 1   0   0
777 1   1   1

I need to identify the single marked Drug(D) columns like below

Expected output

PID D1  D2  D3  Flag
123 0   0   0   NA
234 0   0   1   3
456 0   1   0   2
666 0   1   1   NA
555 1   0   0   1
777 1   1   1   NA

Aucun commentaire:

Enregistrer un commentaire