Hi John,
ggplot usually thinks of the input as “long” data frames, not “wide.” See packages `tidyr` and `reshape2` for more information on how to use tools to convert. But just using your example the way I would do it is:
# same
# I am manually creating the long version, but could be done using `tidyr` or `reshape2`
myd2 <- data.frame(x = c(x, x), y = c(y1, y2), type = c(rep("y1", length(y1), rep("y2", length(y2)))), stringsAsFactors = FALSE)
# Note how you “map” the type on to the color aesthetic
p <- ggplot(myd2, aes(x = x, y = y)) + geom_line(aes(color = type), size = 2)
# if you want to manually set the colors of the lines
p <- p + scale_color_manual(values = c("blue", "red"))
print(p)
Cheers,
Doug