How to change the position of a column in a chart

Unfortunately I'm not very familiar with R Studio yet.
I have the task to create a column chart and can't change the position of the column "HOCH".

The column "HOCH" should appear on the far right of the chart.

I would be grateful for any help. :slight_smile:

library(ggplot2)
library(plotrix)
library(dplyr)

options(scipen=999)
options(digits=3)

PE05_05_DATA <- read.table(file.choose(), header = TRUE, sep = "\t", stringsAsFactors = TRUE)

View(PE05_05_DATA)

PE05_05_DATA$BEWERTUNG <- factor(PE05_05_DATA$BEWERTUNG)

PE05_05_DATA_DESCRIPTIVES <- PE05_05_DATA %>%
group_by(BEWERTUNG) %>%
summarize(MEAN_M = mean(M), SD_SD = sd(SD), SE_SE = std.error(SE))

PE05_05_DATA_DESCRIPTIVES
scale_x_discrete(name="TEST")

ggplot(data=PE05_05_DATA, aes(x=BEWERTUNG, y=M)) +
geom_col (position="identity", fill="lightgrey", width=0.75, colour="black", size=unit(1.0, "pt")) +
geom_errorbar(aes(ymin=M-SE, ymax=M+SE), size=unit(1.0, "pt"), linetype="solid", colour="black", width=0.2) +
scale_y_continuous(name="Mittelwert", breaks=seq(0,15,5), labels=seq(0,15,5), limits=c(0,15), expand=c(0,0)) +
scale_x_discrete(name="Bewertung")+

theme(axis.text.x=element_text(family="Arial", face="plain", colour="black", size=unit(18, "pt"), angle=0)) +
theme(axis.text.y=element_text(family="Arial", face="plain", colour="black", size=unit(18, "pt"), angle=0)) +
theme(axis.line.x=element_line(colour="black", size=1, linetype="solid", lineend="square", color="black")) +
theme(axis.line.y=element_line(colour="black", size=1, linetype="solid", lineend="square", color="black")) +
theme(axis.ticks.x=element_line(size=unit(0, "pt"))) +
theme(axis.ticks.y=element_line(size=unit(1, "pt"))) +
theme(panel.grid.major=element_blank()) +
theme(panel.grid.minor=element_blank()) +
theme(panel.background=element_blank()) +
theme(axis.title.x=element_text(family="Arial", face="plain", colour="black", size=unit(20, "pt"), hjust=0.5, vjust=0.5, lineheight=NULL)) +
theme(axis.title.y=element_text(family="Arial", face="plain", colour="black", size=unit(20, "pt"), hjust=0.5, vjust=0.5, lineheight=NULL)) +
theme(plot.margin=unit(c(1,1,1,1), "cm"))

image

Try changng this line

to

PE05_05_DATA$BEWERTUNG <- factor(PE05_05_DATA$BEWERTUNG, levels = c("GERING", "MITTEL", "HOCH"))

Thank you for taking the time to deal with my problem. Now the diagram looks exactly as I need it. I could cry, many thanks!!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.