I'm trying to make a bar chart to show the average speed of shipping per category per year. my data set is like the following
Category | Order.Date | Speed
Stationary | 2010-5-6 | 3
Supplies | 2011-5-6 | 5
Technology | 2014-5-6 | 3
Supplies | 2013-5-6 | 2
Stationary | 2015-5-6 | 1
I want to make a chart that looks like the following where y-axes are the speed, x-axes are the years, and the color is the category.
I've tried the following code but it returns the same values for y
ggplot(westData, aes(
fill=Category,
y=mean(Speed,na.rm = TRUE),
x=format(Order.Date,"%Y"
))) +
geom_bar(position="dodge", stat="identity")
And I get this message after I run it
"Don't know how to automatically pick scale for object of type difftime. Defaulting to continuous."
I tried to change the Y value to the following
group_by(westData,Category) %>% summarise(avgShippingSpeed=mean(Speed,na.rm = TRUE))
But it returns an error of "Error: Aesthetics must be either length 1 or the same as the data (9553): y"