I\'d like to know how to make it so that x and y, in the following example data set are plotted on the vertical axis for each element of frame in the horizontal axis. How do
This is a rather late answer, but if you want your frame
variable intepreted date (month of the year), then convert it to a date.
You can then use scale_x_date
and the scales
package to format the x-axis
DF <- melt(df, id.vars = 'frame')
# note that I am arbitrarily setting each month to be the 15th
# day of the month, to create a complete date
DF$date <- as.Date(paste0(as.character(df$frame), '15'), '%Y%M%d')
library(scales)
ggplot(DF, aes(x =frame, y = value, colour = variable)) +
geom_line() +
scale_x_date('Month', labels = date_format('%b %Y'), breaks = date_breaks('2 months'))