First is the sample data and some manipulations
A<- c(150,125,0,-300,-350,-370)
Series<-
c("Construction","Manufacturing","Information","Health_Care","Education","Government")
testdf <- data.frame(A,Series)
jobgrowth<-ggplot(data=testdf, aes(y=A, x = reorder(Series,A))) +
geom_col(color="blue") + coord_flip() +
labs(x = NULL) + ggtitle("Interesting Title") +
theme(plot.title.position = "plot",
plot.title = element_text(hjust = 0.5))+
From looking around, I am finding that ggrepel is a good package for this (https://ggrepel.slowkow.com/articles/examples.html). However, my attempts result in an error
Error: geom_text_repel requires the following missing aesthetics: label
So my question is where would insert the labels text and then how to get the data labels to fit on the right when the value is positive and on the left when it is negative? Construction, for example, would have 150 to the right of the bar.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…