I have a dodged bar chart generated from the mtcars dataset showing a histogram of gear vs cyl. I'd like to mark a particular make of car mark on the chart - the chart attached will illustrate this better. The code is doing what it should (points are placed in line with the x axis label cyl) but I'd like the points to align with the correct bar showing the number of gears instead. Any ideas please?
require(graphics)
carsraw <- mtcars
cars <- mtcars %>%
select(cyl,gear) %>%
mutate(cyl=as.factor(cyl),gear=as.factor(gear)) %>%
group_by(cyl,gear) %>%
tally() %>%
rename(count=n)
Hornet <- mtcars %>%
add_rownames("model") %>%
filter(model %in% c("Hornet 4 Drive","Hornet Sportabout")) %>%
mutate(cyl=as.factor(cyl),gear=as.factor(gear)) %>%
mutate(count=7) %>%
select(model,cyl,gear,count)
(ggplot(data=cars)+
aes(x=cyl,y=count,fill=gear) +
geom_bar( position = "dodge", stat="identity")+
geom_point(data=Hornet,size=5)+
aes(x=cyl,y=count,fill=gear))