I am trying to create some rather rudimentary line graphs but can't seem to find the proper functions. I can use the mtcars dataset to try to describe what I want to do, and I hope you'll be able to give me a start in the right direction.

I want to plot cyl on the x-axis and the MEAN value of disp (for each value of cyl) on the y-axis. Using the whole dataset. Then on TOP of that, I want to plot cyl on the x-axis and the mean value of disp on the y-axis BUT ONLY WHEN VS == 1 . Then the same thing, a similar subgroup, for when vs==0. So there will be three lines, each tracing cyl vs disp. Eventually I'll make these different colors/styles too, but for now I'm just trying to get the line graph.

Any thoughts? Many thanks!