I have the height of male and females in my data grouped by cm of 10. I want to plot them togheter side by side.
My graph looks somewhat what I want it to be, but the x-axis says factor(male). It should be height in cm.
Also I got three bars, but there should be two, one for male and one for female.
# Library
library(ggplot2)
library(tidyverse) # function "%>%"
# 1. Define data
data = read.csv2(text = "Height;Male;Female
160-170;5;2
170-180;5;5
180-190;6;5
190-200;2;2")
# 2. Print table
df <- as.data.frame(data)
df
# 3. Plot Variable with column chart
ggplot(df, aes(factor(Male),
fill = factor(Male))) +
geom_bar(position = position_dodge(preserve = "single")) +
theme_classic()


