import library

library(ggplot2)

a function is defined to create a box plot where it takes 2 variables also notch can be added to help in identifiying the mean /median position

plot_density_curves <-function(data,continuous_var,group_var)
{
  ggplot(data,aes_string(x=continuous_var,color=group_var,fill=group_var))+
    geom_boxplot(notch=TRUE,outlier.color="red",outlier.shape = 16,outlier.size = 2)+
    labs(
      title=(paste("boxplot on",continuous_var,"by",group_var)),
      x=group_var,
      y=continuous_var
      )+
    theme_minimal()
  
}

function is called and variables are passed as arguments

plot_density_curves(iris,"Sepal.Length","Species")
## Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
## ℹ Please use tidy evaluation idioms with `aes()`.
## ℹ See also `vignette("ggplot2-in-packages")` for more information.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.