help: why is my percentage on the y axis always messed up when I try to do a box plot

I have my codes over here:
library(tidyverse)
library(ggplot2)

data <- read.csv("data/assassination.csv")
data1 <- data %>% pivot_longer(-Type, names_to = "Attempts", values_to = "Number")

ggplot(data1, aes(x = Type, y = Number, fill = Attempts)) + geom_bar(position = "dodge", width = 0.8, stat = "identity") + scale_fill_grey(start = 0, end = 0.6) + labs(x = "Type", y = "Tenures with assassination attempts (%)") + theme(axis.text.x = element_text(angle = 45, hjust = 1), plot.title = element_text(hjust = 0.5, size = 10, face = "bold")) + theme_bw()

Hello Beverly,
Welcome to the forum, I'm confident you will find It to be a helpful resource.

Appreciating that you are new, you might not be aware of best practices around asking questions (to maximise your chance of getting high quality answers); this is completely understandable, so I will try to help you first by guiding you towards a better posting.

I think it is unclear to the reader how the screenshot table you shared relates to the code you shared.

Given that your title relates to a box plot, I'm suprised your code doesnt contain mention of a relevent geom, it seems to be intending to plot a bar chart with geom_bar. Can you clarify this point ?

Also we can not run your code to try solutions, as we lack your assassination.csv.

Please consider making a reprex of either data, or data1 whatever is more convenient for you, or by inventing example data.

For information on how to reprex you can consult this handy guide if needed.
FAQ: How to do a minimal reproducible example ( reprex ) for beginners

Again, welcome and good luck.

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.