...Good day everyone, Im trying to create a plot with some data, my problem is that it is displaying it incorrectly because it is arranging one column automatically. I need it to display from week -8 to week 8 but instead it displays from week - 1 to week 8 , it is arranging everything automatically despite that I put the data in the order that I need. Heres my code and picture of how the plot looks:
plotData=reactive({
shiny::validate(
need((nrow(values$mydata)>0),"Favor de procesar consulta")
)
vtas=c(values$mydata[1,40],values$mydata[1,41],values$mydata[1,42],values$mydata[1,43],values$mydata[1,44],values$mydata[1,45],values$mydata[1,46],values$mydata[1,47],"0","0","0","0","0","0","0","0")
fcst=c("0","0","0","0","0","0","0","0",values$mydata[1,78],values$mydata[1,79],values$mydata[1,80],values$mydata[1,81],values$mydata[1,82],values$mydata[1,83],values$mydata[1,84],values$mydata[1,85])
dats=data.frame(c("Wk-8","Wk-7","Wk-6","Wk-5","Wk-4","Wk-3","Wk-2","Wk-1","Wk1","Wk2","Wk3","Wk4","Wk5","Wk6","Wk7","Wk8"),vtas,fcst)
colnames(dats) <- c("Weeks","QTY", "Fcst4")
p<-ggplot(data=dats)+
geom_line(aes(x=Weeks, y=QTY, group='Ventas', colour='Ventas')) +
geom_line(aes(x=Weeks, y=Fcst4, group='Fcst', colour='Fcst')) +
geom_point(aes(x=Weeks, y=QTY, group='Ventas', colour='Ventas'))+
geom_point(aes(x=Weeks, y=Fcst4, group='Fcst', colour='Fcst'))+
theme(
panel.background = element_rect(fill = "#ECEFF4", colour = "#ECEFF4",size = 2, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',colour = "white"),
panel.grid.minor = element_line(size = 0.25, linetype = 'solid',colour = "white"),
legend.background = element_rect(fill = "#ECEFF4", color = NA),
legend.key = element_rect(color = "gray", fill = "#ECEFF4"),
legend.title = element_blank(),
legend.text = element_text(color = "black"),
legend.position = "right",
legend.direction = "vertical",
plot.background = element_rect(fill = "#ECEFF4"))
return(p)
})
thanks a lot