I have like below mentioned dataframe:
Records:
ID Remarks Value
1 ABC 10
1 AAB 12
1 ZZX 15
2 XYZ 12
2 ABB 14
By utilizing the above mentioned dataframe, I want to add new column Status
in the existing dataframe.
Where if the Remarks
is ABC, AAB or ABB than status would be TRUE
and for XYZ and ZZX it should be FALSE
.
I am using below mentioned method for that but it didn't work.
Records$Status<-ifelse(Records$Remarks %in% ("ABC","AAB","ABB"),"TRUE",
ifelse(Records$Remarks %in%
("XYZ","ZZX"),"FALSE"))
And, bases on the Status
i want to derive following output:
ID TRUE FALSE Sum
1 2 1 37
2 1 1 26