I have a .csv file, test1.csv
that looks like this:
seed,rate,TYPE,SUFFIX
1,1,A,Sim
1,1,A,Ana
2,1,A,Ana
2,2,A,Ana
1,1,B,Sim
1,1,B,Ana
2,1,B,Ana
2,2,B,Ana
1,1,C,Sim
2,2,C,Ana
I want to set alpha = 1
for rate = 1
and
alpha = 0
for rate = 2
I have the following R code:
require(ggplot2)
require(scales)
require(dplyr)
pdf(file="sweep_feasibility-vs-injection_test.pdf", height=3, width=6)
a<-read.csv('./test1.csv',header=T);
a$alphayr <- as.factor(ifelse(a$rate == 1, TRUE, FALSE))
a<-na.omit(a)
p<-ggplot(a,aes(x=rate,group=factor(SUFFIX))) +
geom_bar(stat="count", position = "dodge", aes(fill=factor(SUFFIX), alpha=alphayr))+
scale_alpha_manual(values = c(0,1), guide = F) +
facet_grid(~TYPE)+
xlab('Injection Rate (%)') +
ylab('Feasible (%)');
p + theme_bw() %+replace% theme(axis.title=element_text(),axis.title.y=theme_bw()$axis.title.y) +
theme(
axis.line=element_line(color='black'),
legend.position="top",
legend.background=element_rect(fill="transparent"),
axis.title.x = element_text(size=15),
axis.title.y = element_text(size=15),
panel.border=element_blank(),
panel.grid.minor = element_blank(),
panel.grid.major.x = element_blank(),
legend.key.width=unit(0.5,"cm"),
legend.key.height=unit(0.5,"cm"),
plot.title = element_text(hjust = 0.5),
legend.key = element_rect(colour = "black", size=0.1),
legend.title=element_text(size=10),
axis.text.y=element_text(size=15,color='black'),
axis.text.x=element_text(angle=0,hjust=0.5, size=15, color='black'),
legend.text=element_text(size=15))+
guides(
fill=guide_legend(nrow=1,title=""),
color=guide_legend(nrow=1,title=""),
shape=guide_legend(nrow=1,title="")
);
when I run this code, I get the following graph:
I don't understand why I am seeing a bar for rate = 2