I'm trying to export a ggplot graphic to Word using plot2docx (from the rrtable package). I have this code for the data:
data0 = data.frame(
GrR=c("Ejército Nacional","Paramilitares","Farc","Policía Nacional",
"Sin información","Grupo armado","Grupos de limpieza social",
"DAS","ELN","CTI","Otros agentes del Estado"),
Cantidad=c(127,49,11,5,5,4,3,3,1,1,1)
)
data0$GrR = factor(
data0$GrR,
levels = c("Ejército Nacional","Paramilitares","Farc","Policía Nacional",
"Sin información","Grupo armado","Grupos de limpieza social",
"DAS","ELN","CTI","Otros agentes del Estado"))
This for the plot:
z = ggplot(data=data0, aes(x=GrR, y=Cantidad)) +
geom_bar(stat="identity", width=0.5, fill = "blue") +
geom_text(aes(label=scales::comma(Cantidad, scale = 1, accuracy = 1)),
vjust=0.6,
hjust=-0.5,
color="black",
position = position_dodge(0.5), size=5) +
ggtitle("Víctimas de desaparición, según presunto grupo armado responsable") +
labs(y="", x="") +
coord_flip() +
theme_minimal() +
theme(plot.title = element_text(color="black", size=16, face="bold", hjust = 0.5)) +
theme(axis.text.x=element_blank())
This for sending it to word:
plot2docx(z)
It gives me this:
As you see, the title is incomplete. Also, the value of the last bar is not displayed. I have tried adding height and width specifications, but the image remains the same. Any idea on how to solve it? Thank you in advance.