Hi,
Needed advise.
In given data set,
I am trying to get couple of things:
-
sort by column A where i need to defined ranks (100=1 and 110=2)
-
unique values in column x where column B ="b" and B != "b" seperately using group by.
and create new column for 1 ="b" & 0!="b"
Dataset
ab = data.frame(x = c("P1","P1","P1","P2","P2","P2","P3","P3","P3","P4","P4","P4"),
A = c("100","110","100","110","100","110","100","110","100","110","100","110"),
B = c("A1","A2","A3","A4","A5","A6","A7","A8","A9","A10","A11","A12"),
c= c("ab","ab","ab","ac","ac","ac","bb","bb","bb","bc","bc","bc"),
D= c("a","a","a","a","b","a","b","b","b","a","a","b"),
stringsAsFactors = FALSE)
Desired Output is
x A B C D New
1 P1 100 A1 ab a 0
2 P2 100 A5 ac b 0
3 P3 100 A7 bb b 1
4 P4 100 A11 bc a 0