I have a data as follows.
df <- data.frame(Type=c(1,2,3,4,5), Category1=c(0,1,0,1,0), Category2=c("0.00 %", "1.00 %", "1.00 %", "1.00 %","0.00 %"), Category3=c(0,1,1,0,0),Category4=c("0.00 %", "1.00 %", "1.00 %", "1.00 %","1.00 %"))
I want to only check those rows with 0 and 0.00%.
a <- df[which(df[,2:ncol(df)] == 0),1]
b <- df[which(df[,3:ncol(df)] == sprintf("%.2f %%", 100*0)),1]
intersect(a,b)
It seems 2:ncol(df)
is not working.
Expected Result, the return of intersect(a,b) should only be 1.