so I have found a way to over lay my KDE density function with my histogram using ggplot2, however what I've noticed is my histogram y axis is frequency which is correct, but I want to make a secondary y axis for my density plot, I also dont know how to scale up my density plot.
the code im using is:
data_set <- mammals
library(ggplot2)
ggplot(data=data_set, aes(data_set$`Total Averages`))+
geom_histogram(col='black', fill = 'white', binwidth = 0.5)+
labs(x = 'Log10 total body mass (kg)', y = 'Frequency', title = 'Average body mass (kg) of mammalian species (male and female)')+
geom_density(col=2)
I have posted the link to the image below of what my plot looks like