This is a really basic question but I can't find a similar one, so I'm asking here. I want to create multiple ggplots (xy-charts specifically) using the same x and a different y, all from the same data frame (using the values in one column for x and each of the other columns for a y).
My first approach would have been to use a for loop to cycle through the table, but inputting a string (as would result from, say, colnames(mtcars[i])):
ggplot(data=mtcars,aes(x=mpg,y="cyl"))
is interpreted completely differently from
ggplot(data=mtcars,aes(x=mpg,y=cyl))
What would be the correct approach to this (other than copying, pasting and replacing the input of y every time, of course)?