# Required Packages library(deSolve) library(ggplot2) solution <- ode(y=c(volume=100), times=seq(0, 10, by = 0.1), func = function(time, state, parameters) { volume = state[1] d_volume = -0.1*time return(list(d_volume))},) df <- as.data.frame(solution) head(df) # Plot the volume over time plot <- ggplot(df, aes(x = time, y = volume)) + geom_line() + xlab("Time") + ylab("Volume") + ggtitle("Draining Water Tank") + theme_minimal() # Save the plot as a PDF file ggsave("draining_water_tank.pdf", plot, width = 8, height = 6)