I have a additional question to R ggplot2 wrap long x-axis labels over multiple rows because of my problem with the
gsub(" ", "\n", levels())
I try to include it in the following R Code:
ggplot(ntry[!is.na(ntry$V138), ], aes(x=V138, group=1)) +
geom_bar(aes(y = ..prop.., fill = factor(..x..)), stat="count", fill="#008000", width=0.5) +
geom_text(aes(label = gsub("\\.",",",scales::percent(..prop..)), y= ..prop.. ), stat= "count", vjust = -0.5, color="black", fontface= "bold") +
theme(axis.text= (element_text(face="bold", size="9", color="black")), axis.title = (element_text(face="bold", size= "9", color="black")), panel.background = (element_rect(fill="#FFFFFF")), axis.line = (element_line(color="black"))) +
scale_y_continuous(labels=percent) +
xlab(" ") +
ylab("Prozent") +
ggtitle(paste(attr(ntry, "variable.labels")[grep("^V138$", colnames(ntry))]))
My goal is to get the x-axis-labels in multiple rows. I tried every point in my code I could think or imagine of the possibility it would fit. My main point I tried to integrate gsub was in the part of theme(axis.text= (element_text(face behind the third bracket.
It would be fabulous if someone could help me. I do not see the rigth option.
Thank you