Got it thank you
From: Riley Finn <rileyfi...@gmail.com> Sent: Thursday, August 23, 2018 10:24 PM To: reichm...@sbcglobal.net Cc: R-help@r-project.org Subject: Re: [R] How to add a geom_smooth() line Jeff, You need to reshape your data frame. If you use ggplot, you will often have to present your data in "long format" Use the reshape2 package. I made a sample data frame because you didn't provide one. I also change your x and y labels because they made no sense. data <- data.frame( timeline = 1:10, launches = sample(10:20, 10), deliveries = sample(10:20, 10) ) library(reshape2) dataNew <- melt(data = data, id.vars = 'timeline', variable.name <http://variable.name> = 'launchOrDelivery') ggplot(data=dataNew, aes(x=timeline, y=value), color= launchOrDelivery) + geom_point(aes(color= launchOrDelivery)) + geom_smooth(aes(group = launchOrDelivery, color= launchOrDelivery), se = FALSE) + xlab("timeline") + ylab("Launches/Deliveries") + ggtitle("Scatterplot of Launches vs. Deliveries") On Thu, Aug 23, 2018 at 9:39 PM Jeff Reichman <reichmanj@sbcglobalnet <mailto:reichm...@sbcglobal.net> > wrote: R-help I want to add two smooth lines (geom_smooth()) for each scatter plot. How do I do that? ggplot() + geom_point(data=data, aes(x=timeline, y=deliveries), color="blue") + geom_point(data=data, aes(x=timeline, y=launches), color="red") + xlab("Deliveries") + ylab("Launches") + ggtitle("Scatterplot of Launches vs. Deliveries") Jeff [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org <mailto:R-help@r-project.org> mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.