I want to color the tiles in a geom_tile plot for the combinations for which the chi-square hypothesis is accepted as grey. Add color gradient based on chi-square value for the combinations for which the hypothesis is rejected. Now, the logical values for accepted or rejected is stored in a variable called AR. X3 is the variable used to create color gradient.
What I have tried?
I could only add two different colors if accepted or rejected.
G1<-ggplot(df, aes(x = X1, y = X2)) +
geom_tile(aes(fill = AR), colour="black") +
geom_text(aes(fill = AR, label = ifelse(AR==1,X3,'')))+
xlab("V1")+
ylab("V2")+
scale_fill_manual(values = c("grey", "green"))
show(G1)
A dummy dataset:
X1 X2 AR X3
A SUV Yes 12
A SUV No 22
B SUV No 8
B SUV Yes 50
C car Yes 27
C SUV No 99
D SUV Yes 33
D van Yes 13
E car No 65