Hello, thanks to your help!
You will find hereafter my code.
I have 3 variables.
I want to represent these three variable as follow :
_ 2 variables on 1 bar
_ 1 variable on 1 bar
for each position x
I created 2 arrays :
_ kpi.project_1.tdy for 2 variables
_ kpi.project_2.tdy for 1 variables
Error message :
`data` must be a data frame, or other object coercible by `fortify()`, not a character vector
kpi.project_1.tdy<-kpi.project %>%
gather("types","heures",3:4)
print(kpi.project_1.tdy)
#creation de la version tidy de kpi.project heures commandées
kpi.project_2.tdy<-kpi.project %>%
gather("types","heures",2:2)
print(kpi.project_2.tdy)
var_1<-factor(kpi.project_1.tdy$pas, levels = (unique(kpi.project_1.tdy$pas)), ordered=FALSE)
var_2<-factor(kpi.project_2.tdy$pas, levels = (unique(kpi.project_2.tdy$pas)), ordered=FALSE)
barwidth = 0.35
ggplot() +
geom_bar(data = kpi.project_1.tdy$pas,
mapping = aes(x=var_1 , y=heures,fill=types),
stat ="identity",
position = "stack",
width = barwidth) +
geom_bar(data = kpi.project_2.tdy$pas,
mapping = aes(x=var_2 + barwidth + 0.01 , y=heures,fill=types),
stat ="identity",
position = "stack",
width = barwidth) +
xlab("pas") + ylab("heures") +
labs(fill = "type d'heure")+
theme(
panel.background = element_blank(),
panel.grid.minor = element_blank(),
panel.grid.major = element_line(color = "gray50", size = 0.5),
panel.grid.major.x = element_blank(),
axis.text.y = element_text(colour="#68382C", size = 9))
thanks in advance to your help!